sttimchenko
sttimchenko

Reputation: 431

How to use only my app for intent-filter URL with specific prefix?

Suppose we have an activity to resolve external URL links with a specifix pathPrefix. It's not a problem. The problem is to have a method to make those links is only resolvable with my app. For example: We have this 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="/specific_prefix/"
         android:scheme="http" />
</intent-filter>

And I want only my app to be used for example for "example.com/specific_prefix/etc". If that eve possible?

Upvotes: 0

Views: 904

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006539

And I want only my app to be used for example for "example.com/specific_prefix/etc". If that eve possible?

No.

First, how URLs are interpreted is up to the app interpreting the URLs. Some Web browsers, when they encounter an http URL, will always handle it themselves, rather than seeing if a third-party app has advertised support for it.

Second, in cases where there are two or more apps that claim to support a certain operation, the user chooses which one to use. In your case, Web browsers and your app will claim to handle that URL, and the user can choose whichever of those that the user wants.

With Android 6.0's app links, you can avoid the chooser by default, so if a chooser would have appeared, the user will be taken straight to your app. The user can disable this in Settings, though.

Upvotes: 1

Related Questions