I have used the following code to handle deep links in Android
<!-- Deep linking -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="mywebsite.com" />
<data android:scheme="https" />
</intent-filter>
But when I set the scheme to HTTP or HTTPS, it doesn't work and the website opens in the browser.
This code opens the website in the browser:
<data android:scheme="http" android:host="mywebsite.com" />
This code will open my app:
<data android:scheme="myapp" android:host="app" />
You cannot request domain login for android app. If you want a web project, then you should write codes related to the web project. Even then, you'll be using "localhost".
In android:host="app.page.link" would be same as you set in your firebase dynamic link
It should look like this
Related
I have an implementation of deeplink in my manifest which is working fine
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="blablabla.com"
android:scheme="https" />
<data
android:host="${applicationId}"
android:scheme="bla" />
</intent-filter>
I am wondering is there any way to NOT ACCEPT a deep link URL if it contains a specific path? E.g. Do not accept (don't open the app) if blablabla.com/specificPath but do accept any other paths with the same hostname.
Android Deep Links does not provide a way to explicitly exclude URLs, the best practice is define specifically the urls that you want to access to your app using deep Links.
In this case to access URLs like :
www.blablabla.com/specificPath
www.blablabla.com/specificPath/
www.blablabla.com/specificPath/default.aspx
www.blablabla.com/specificPath/other/
You will define the configuration of your intent filter using android:pathPrefix as:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="blablabla.com"
android:scheme="https"
android:pathPrefix="/specificPath" />
</intent-filter>
I want to put deep linking with all the link looking like this :
https://myapp.com/*/*/quiz.html
How can I do that ? I try this intent-filter in my Manifest but the pathPrefix is not working :
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="myapp.com"
android:pathPrefix="/.*/.*/quiz\\.html"/>
</intent-filter>
Without the android:pathPrefix it's working but it's opening all the links from https://myapp.com.
You have to use android:pathPattern in your data element.
<data
android:host="myapp.com"
android:pathPattern="/.*/.*/quiz.html"
android:scheme="https" />
Then you can set any url pattern you want to open in your app. Read documentation . Also, here is good explanation about how it works.
In my android app code Manifest file contains following Intent filter for handling a Link in the app but doesn't work
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="safimoney.com"
android:pathPrefix="/.*/transactions/request-money/confirm/.*" />
</intent-filter>
test it with link generated from web "https://safimoney.com/en/transactions/request-money/confirm/0CnpXE7u5hXRD1JVcZM2APHcYElKZvBZs8GeqimJ" but it doesn't ask for an open link in the app.
If you want your app to open a link, use below code.
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
It will ask to select browser while opening this link.
You wanna do a Deep Link, right?
<intent-filter>
<data
android:host="open"
android:scheme="companyName" />
<data
android:host="companywebsite.com"
android:scheme="http" />
<data android:scheme="https" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
I would suggest for you take a look in Branch.io for link-app solutions.
But if you wanna make a webView inside your app this tutorial can help you.
This is one of the cases where developer.android website has everything that you need, even code examples. Just need to ready with a lot of attention. Hope it helps
EDIT
About your data, looking on android developer website, this should be the better way to set:
<data
android:scheme="https"
android:host="safimoney.com"
android:pathPrefix="/en/transactions/request-money/confirm/" />
But even after this you should add a data like this
<data android:scheme="safimoney"
android:host="/en/transactions/request-money/confirm/" />
I have a activity that apply intent filter to open deeplink, this is my intent filter :
<intent-filter android:autoVerify="true">
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.example.com"
android:pathPattern="/..*"
android:scheme="https" />
</intent-filter>
my problem is, when user open a link i.e "www.example.com/somepage" from messaging apps e.g Hangout,Whatsapp, Android app chooser doesn't display may apps in its list, it just show all browser app in the options. But when user put "https://www.example.com/somepage" in a message then it works, Android show my app in its App chooser to open the link.
It also doesn't work When I try to remove android:scheme="https" from my intent filter.
is there anyone has same problem and have a solution?
Any help really appreciated.
This is expected behavior.
What the following snippet does is register your app as a handler for the URL scheme https://
<data
android:host="www.example.com"
android:pathPattern="/..*"
android:scheme="https" />
This means your app will be offered as an option for any link beginning with https:// and containing www.example.com. The string www.example.com/somepage doesn't qualify, as it is missing the https:// part.
You could try adding a second filter for http:// links. I'm not sure if Android automatically infers that as the scheme for web links without a scheme specified, so it's possible this could resolve the issue.
<intent-filter android:autoVerify="true">
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.example.com"
android:pathPattern="/..*"
android:scheme="https" />
<data
android:host="www.example.com"
android:pathPattern="/..*"
android:scheme="http" />
</intent-filter>
When user type the url to my .someExt file in his web browser (on Android Phone), the message appears:
This content is unsupported content. Do you really want to download?
Instead, I would like to associate the .someExt (my custom file extension) with my Android Application (that the user has downloaded previously) so when user type the url to .someExt in browser my Application will open the file.
How to achieve it? I guess it has to be done with manifest and some "handle" method in my Activity.
Based on: Associate App with file extension - Intent filter Not working?
I have used:
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/someExt" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="*" />
<data android:scheme="file" />
<data android:scheme="smb" />
<data android:scheme="content" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.someExt" />
</intent-filter>
</activity>
Now, when user type the url to my .someExt the file is being downloaded and I can open it when downloading is done (so my Application will run it). But I don't want all those additional clicks - I want it to be:
User click the link to .someExt on the website.
The .someExt opens in my Android Application.
And not the:
User click the link to .someExt on the website.
The file starts to download.
User open "downloads" and click on downloaded file.
The .someExt opens in my Android Application.
I don't think you can realize this feature in Android with different kind of browsers. The URL user type is handled by the browser most of the time. How to deal with the scheme is decided by the behaviors of the browser. If your scheme is http, the browser will try to open with it own and handle by itself.
Currently, most browsers add support for market scheme. If the URI's scheme is market, it will jump to Google Play or other markets.
But is can be done from other app with Intent.
Declare your activity like following to receive the ACTION_VIEW action.
<activity
android:name=".MainActivity2Activity"
android:label="#string/title_activity_main_activity2">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="com.example.myapp"
android:mimeType="*/*"
android:pathPattern=".*\\.someExt"
android:scheme="http" />
</intent-filter>
</activity>
From other apps, you could do like this.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://com.example.myapp/test.someExt"), "*/*");
intent.setPackage("com.example.myapplication");
startActivity(intent);