I am trying to create a deep link to match a URL specifically on the specified domain, and not on any subdomains. My intent filter <data />
entry looks like this:
<data
android:host="example.com"
android:pathPrefix="/somepath"
android:scheme="https" />
This works fine, and matches URLs with https://example.com/somepath
as I'd expect. However, there are also URLs that I have that look like https://subdomain.example.com/somepath
that I do not want to match. These are picked up by that data entry as well!
I want to match STRICTLY on the host and not include any subdomains. Is this possible in Android?
It's not possible to change the URL scheme for either set of links.
As I see in the documentation, your configuration will not match with subdomains.
If you want to accept all subdomains you have to use an asterisk (*
) character before your host like this: *.example.com
.
So, the answer is: example.com
will not match with any subdomains like subdomain.example.com
I have created and Activity with the following intent-filter
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="example.com"
android:pathPrefix="/somepath"
android:scheme="https" />
</intent-filter>
This opens test.example.com in a browser window:
adb shell am start -a android.intent.action.VIEW -d "https://test.example.com/somepath/test"
This opens my application:
adb shell am start -a android.intent.action.VIEW -d "https://example.com/somepath/test"
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