How to open app from a link without asking user to decide between browser or app, just open my app immediately

Jeka picture Jeka · Dec 18, 2015 · Viewed 20.9k times · Source

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: enter image description here

Which then opens a dialog which asks user if they want this link to be opened from my app or browser like this:

enter image description here

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?

Answer

ianhanniballake picture ianhanniballake · Dec 18, 2015

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.