I am trying to get App Links working on my Android app but am unable to figure out why it doesn't work.
I have added the following intent-filter tag to my Manifest file:
<activity android:name=".MyActivity">
<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="www.mywebsite.com"
android:pathPattern="(/[a-z]{2}|)/foo/bar" />
</intent-filter>
<activity android:name=".MyActivity">
In MyActivity.java
I have:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
handleIntent(getIntent());
}
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
handleIntent(intent);
}
private void handleIntent(Intent intent){
String appLinkAction = intent.getAction();
Uri appLinkData = intent.getData();
if (Intent.ACTION_VIEW.equals(appLinkAction) && appLinkData != null){
//Do something here
}
}
I have also added the auto-generated digital asset links file to my website. It shows up just fine at https://www.mywebsite.com/.well-known/assetlinks.json
The following verification link checks out as well:
https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://www.mywebsite.com&relation=delegate_permission/common.handle_all_urls
I have installed a signed apk on an actual device running Android 7.0. Upon installation, I can see in the logs of my web server that the device successfully obtains the assetlinks.json file.
As a result, running adb shell dumpsys package d
shows the following:
App linkages for user 0:
Package: com.myapp.myapp
Domains: www.mywebsite.com
Status: always : 20000001f
I sent an email to myself with the link https://www.mywebsite.com/foo/bar
and it just opens the app chooser dialog without even suggesting my app. It only shows browser options.
Clicking a link such as maps.google.com
does open the Maps app directly. Which leads me to think the problem doesn't have anything to do with the phone's settings.
What am I missing?