如何忽略来自Intent Filter的特定URL集。 现有过滤器。
private ShareActionProvider mShareActionProvider;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate menu resource file.
getMenuInflater().inflate(R.menu.menu_main, menu);
// Locate MenuItem with ShareActionProvider
MenuItem shareItem = menu.findItem(R.id.menu_item_share);
// Fetch and store ShareActionProvider
mShareActionProvider = (ShareActionProvider)shareItem..getActionProvider();
setShareIntent(getDefaultShareIntent());
// Return true to display menu
return true;
}
// Call to update the share intent
private void setShareIntent(Intent shareIntent) {
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(shareIntent);
}
}
/** Returns a share intent */
private Intent getDefaultShareIntent(){
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "SUBJECT");
shareIntent.putExtra(Intent.EXTRA_TEXT,"Extra Text");
return shareIntent;
}
使用上述过滤器,所有网址都会在应用中打开。我想忽略几个网址&它必须使用浏览器打开。 要忽略的网址示例。
<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>
以下代码会直接打开该应用。
https://www.example.com/privacy-policy
https://www.example.com/tos
https://www.example.com/faq