Reputation: 195
My app has an activity for opening YouTube links, with intent filters which I've copied from NewPipe. It works fine: when I click on a YouTube link, Android asks me which app to use, and my application appears in the list. The problem is, it asks me this every time, even after I go to the settings and select "Open in this app".
NewPipe works as expected: after choosing "Open in this app", it's used to open YouTube links every time, without asking.
Here's the AndroidManifest portion for my activity, copied from here:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<!-- Youtube filter, copied from NewPipe -->
<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" />
<data android:host="youtube.com" />
<data android:host="m.youtube.com" />
<data android:host="www.youtube.com" />
<data android:host="music.youtube.com" />
<!-- video prefix -->
<data android:pathPrefix="/v/" />
<data android:pathPrefix="/embed/" />
<data android:pathPrefix="/watch" />
<data android:pathPrefix="/attribution_link" />
<!-- channel prefix -->
<data android:pathPrefix="/channel/" />
<data android:pathPrefix="/user/" />
<data android:pathPrefix="/c/" />
</intent-filter>
<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" />
<data android:host="youtu.be" />
<data android:pathPrefix="/" />
</intent-filter>
</activity>
Upvotes: 0
Views: 428
Reputation: 195
I haven't done any tests to conclusively answer this, but I think in my case this was because my app didn't have a "main activity". I've added a proper activity with categories LAUNCHER and DEFAULT and now the app behaves as I expect.
This could be a security feature, to prevent "hidden" apps from hijacking somebody's intents.
Upvotes: 1