Reputation: 36289
I have an Android app that should open links sent via email. I only want to open links to a certain website, though. I know that opening youTube links provides the user with a dialog asking whether to open it in the browser or in the youTube app, so this is what I am going for. In my android manifest file, I have the following intent filters:
<activity android:name=".MyApp"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http"
android:host="mySite.com" />
</intent-filter>
</activity>
Then, to handle the intent, I have a line in onCreate:
if (getIntent().getCategories().contains("android.intent.category.BROWSABLE")){...}
The problem is that links such as http://mySite.com#12345 are not opening this way. What am I doing wrong?
Upvotes: 6
Views: 6530
Reputation: 36289
The answer was to add the default category to the second intent filter, just as @advantej suggested.
Upvotes: 6