Currently, I have a deep link integration in my app
<activity android:name="org.yccheok.jstock.gui.news.NewsListFragmentActivity"
android:theme="@style/Theme.JStock.Toolbar.Transparent.Light"
android:windowSoftInputMode="stateAlwaysHidden" >
<intent-filter>
<!-- Sets the intent action to view the activity -->
<action android:name="android.intent.action.VIEW" />
<!-- Allows the link to be opened from a web browser -->
<category android:name="android.intent.category.BROWSABLE" />
<!-- Allows the deep link to be used without specifying the app name -->
<category android:name="android.intent.category.DEFAULT" />
<!-- Accepts URIs that begin with "http://jstock.co/a/news” -->
<data android:scheme="http"
android:host="jstock.co"
android:pathPrefix="/a/news" />
</intent-filter>
</activity>
When user clicks on a received link with the following format
http://jstock.co/a/news?code=XOM&symbol=Exxon+Mobil+Corpo
Assuming this is a user with app installed. The following screen will be shown

If user chooses the native app JStock, native app will be launched and he will get useful information.
However, if user choose chrome and click JUST ONCE, it isn't much useful. Worst still, if user choose chrome and click ALWAYS, the native app will never have chance to be launched via deep link.
I was wondering, what is some good ways to avoid such problem? How can we ensure the deep link will always open up our own native app instead of open up chrome browser?
Thanks for @CommonsWare. I had change my AndroidManifest.xml to
<activity android:name="org.yccheok.jstock.gui.news.NewsListFragmentActivity"
android:theme="@style/Theme.JStock.Toolbar.Transparent.Light"
android:windowSoftInputMode="stateAlwaysHidden" >
<intent-filter android:autoVerify="true">
<!-- Sets the intent action to view the activity -->
<action android:name="android.intent.action.VIEW" />
<!-- Allows the link to be opened from a web browser -->
<category android:name="android.intent.category.BROWSABLE" />
<!-- Allows the deep link to be used without specifying the app name -->
<category android:name="android.intent.category.DEFAULT" />
<!-- Accepts URIs that begin with "http://jstock.co/a/news” -->
<data android:scheme="http"
android:host="jstock.co"
android:pathPrefix="/a/news" />
<!-- Accepts URIs that begin with "https://jstock.co/a/news” -->
<data android:scheme="https"
android:host="jstock.co"
android:pathPrefix="/a/news" />
</intent-filter>
</activity>
I also ensure https://jstock.co/.well-known/assetlinks.json is accessible with the following content.
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "org.yccheok.jstock.gui",
"sha256_cert_fingerprints":
["F4:6B:DF:4F:21:74:72:2F:88:E0:4C:09:2A:0C:00:C8:9A:16:D0:C6:DB:9C:BC:46:17:93:52:F4:35:AE:DB:98"]
}
}]
Still, clicking on http://jstock.co/a/news?code=XOM&symbol=Exxon+Mobil+Corpo , still giving user choice to choose Chrome.
I'm tested using Android 6, with APK compiled with released key.
Is there anything I had missed out?
Set up the assetlinks.json file and ask for verification, per the documentation. On Android 6.0+, if your assetlinks.json can be found and validated, your app will be used for the URLs handled by your <intent-filter>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With