How to open app from a link without asking user to decide between browser or app, just open my app immediately
Solution 1
Bypassing the disambiguation dialog is only possible with the Android 6.0 API for App Linking.
Per the Handling App Links training:
Android 6.0 (API level 23) and higher allow an app to designate itself as the default handler of a given type of link. If the user doesn't want the app to be the default handler, they can override this behavior from Settings.
Automatic handling of links requires the cooperation of app developers and website owners. A developer must configure their app to declare associations with one or more websites, and to request that the system verify those associations. A website owner must, in turn, provide that verification by publishing a Digital Asset Links file.
This involves creating the appropriate intent handler and enabling automatic verification by adding android:autoVerify="true"
:
<activity ...>
<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="www.android.com" />
<data android:scheme="https" android:host="www.android.com" />
</intent-filter>
</activity>
Then, updates must be made on the website side by declaring a website association, which ensures that the website owner and the app developer both coordinate to allow the app to autoomatically become the default for a URL scheme.
Solution 2
Here are a couple of places you can use to verify that .well-known/assetlinks.json
is accessible, which is an important prerequisite for removing the disambiguation dialog.
https://developers.google.com/digital-asset-links/tools/generator
As for my case, despite everything checks, the disambiguation dialog just wouldn't go away. It turned out that I was also using FirebaseUI Auth for GitHub (https://github.com/firebase/FirebaseUI-Android/tree/master/auth), which uses firebase_web_host
; if it's defined as something other than the value defined in android:host
, then android:autoVerify
also fails as well.
The problem was, firebase_web_host
was buried somewhere outside of my code, so it wasn't exactly obvious why android:autoVerify
was failing. One easy way to find out is to check adb logcat
when installing the app; you should see something like
IntentFilterIntentSvc: Verification .. complete. Success:true. Failed hosts:.
If you see Success:false
, it should show which hosts failed, so that should give you a clue on where to look.
Solution 3
all you have done is correct just change https and http with another word wirte 'app' example data android:scheme="app" android:host="com" android:pathPrefix="/easy"
http or https means run browser then cause conflict
Solution 4
in your AndroidManife.xml put
<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="myAPP" />
</intent-filter>
for example
<activity
android:name="Activity"
android:exported="true"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<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:scheme="myAPP" />
</intent-filter>
</activity>
after that when click on any url with scheme "myAPP" Your application will open No user requests
for example URL
Jeka
Updated on July 09, 2022Comments
-
Jeka almost 2 years
I have this
intent-filter
that I want that every time user clicks a link to eeexample.com to open my app:<intent-filter> <data android:scheme="http" /> <data android:scheme="http" android:host="eeexample.com"/> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter>
When user clicks eeexample.com on gmail app for example:
Which then opens a dialog which asks user if they want this link to be opened from my app or browser like this:
But I just want that when user clicks the link it opens ONLY my app without asking anything. Or in a worst case scenario to just ask to open it with my app which is Appetit not with browser. Is this possible?
Update
So it seems this is possible to do with App Links but only for API level 23 (Android 6.0), but I need this for api level 15 (Android 4.0), any ideas?