Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 339
Jeka Avatar asked Dec 18 '15 16:12

Jeka


People also ask

How do I open a website without opening an app?

Tap on the app. On the next page, tap Open supported links and it will show you three options- “Allow app to open supported links, Always Ask, Don't allow app” to open links. You should select 'Don't allow the app to open links' to stop it from opening every time. Restart the phone, and that's it.


1 Answers

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.

like image 193
ianhanniballake Avatar answered Oct 01 '22 01:10

ianhanniballake