6

How to ignore specific set of URLs from Intent Filter. Existing filter.

<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="www.example.com" android:scheme="http" />
    <data android:host="www.example.com" android:scheme="https" />
    <data android:host="example.com" android:scheme="http" />
    <data android:host="example.com" android:scheme="https" />
</intent-filter>

With the above filter, all URLs opens in the app. I want to ignore few URLs & it has to opened using browser. Example urls to be ignored.

https://www.example.com/privacy-policy
https://www.example.com/tos
https://www.example.com/faq

The below code directly opens the app.

Uri uri = Uri.parse("https://www.example.com/privacy-policy");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent); // Opens the app directly.
// startActivity(Intent.createChooser(intent, "Select browser")); // Shows current app only.
VenomVendor
  • 15,064
  • 13
  • 65
  • 96
  • 4
    `` is a whitelist, not a blacklist. There is no "except-for" mechanism in ``. You would need to come up with the right set of `` and `` elements to enumerate all the URLs that you do support. This will be rather lengthy. – CommonsWare Apr 16 '16 at 11:51
  • What **android:pathPattern** have you tried? – IgorGanapolsky Oct 19 '17 at 17:51

0 Answers0