In my android app I support opening web sites either in my application or in external browser.
So I’ve added the following code to android manifest:
<activity
android:name=".MyActivity"
android:screenOrientation="portrait" >
<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:scheme="http" />
<data android:scheme="https" />
</intent-filter>
</activity>
So now when user tries to open some url he sees a dialog in which he can choose preferable app to view this url. But I want my application to appear in this dialog only for urls opened from inside my app. I don’t want it to appear, f.e., when user tries to open some external link in Facebook application. Are there any ways to do that?
Note that my app supports opening of different links and I can’t set any specific pattern for them.
This is not possible, sorry.
You might be able to fake this behavior through enabling and disabling this component via
PackageManagerandsetComponentEnabledSetting(), such that it is only enabled when it is likely that such a URL will be encountered. However, it may be difficult to get this to be 100% reliable.