2

I have an Android app which needs to handle deep links, and I have installed a <server>/.well-known/assetlinks.json file as documented.

I am hoping I can use the assetlinks.json file to specify a more complex URL matching pattern than the AndroidManifest.xml intent-filter allows.

Currently my assetlinks.json looks like this:

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.example.myapp",
    "sha256_cert_fingerprints": ["12:34:...:CD:EF"]
  }
}]

What are the options for the "relation": ["delegate_permission/common.handle_all_urls"] entry? The name surely implies that there must be other options than handling all URLs, but I can't see how to specify what URLs to handle.

The Statement List Syntax doesn't offer any example other than common.handle_all_urls and the detail just says "If you want to create a statement that does not fit one of these statement types, you can define your own unique string." But how?

For example I want to:

  • Handle all URLs matching https://server.example.com/project/*
  • Except DO NOT handle https://server.example.com/project/upload

The app's AndroidManifest intent-filter has URL configuration options through android:pathPrefix etc, but AFAIK it does not allow this kind of exclusion which is why I am hoping to use the assetlinks.json file. (The intent-filter android:pathAdvancePattern property does not work below Android 12, so is not enough to solve the problem.)

Ben
  • 1,881
  • 17
  • 20
  • Does this answer your question? [Handling specific routes in Android M app links](https://stackoverflow.com/questions/35840262/handling-specific-routes-in-android-m-app-links) – Agent_L Aug 30 '23 at 12:32

1 Answers1

0

I'd still like to know a full answer to this question explaining how the assetlinks.json file delegate_permission entry works, but I have a workaround for my problem. My statement "The intent-filter android:pathAdvancePattern property does not work below Android 12" turned out to be incorrect and it does work, at least back to Android 7/SDK 24 when I tested. To achieve the exclusion I wanted, I used this intent filter on my 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:host="server.example.com" />
    <data android:pathAdvancedPattern="/project/[^(upload)]+" />
</intent-filter>

I am building with:

minSdkVersion=24
compileSdkVersion=33
targetSdkVersion=33
Ben
  • 1,881
  • 17
  • 20