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.
<intent-filter>
is a whitelist, not a blacklist. There is no "except-for" mechanism in<intent-filter>
. You would need to come up with the right set of<intent-filter>
and<data>
elements to enumerate all the URLs that you do support. This will be rather lengthy. – Electroanalysis