I’ve seen in some apps that when you click on a link it asks you if you want to open it in an app. I’ve seen in many posts that you can do
<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:host="www.ex-ample.com" android:scheme="http" />
</intent-filter>
I haven’t tried it, but every post seems to say it works. What I tried was:
<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:mimeType="vnd.android.cursor.item/vnd.example.crag" />
<data android:host="www.ex-ample.com" android:scheme="http" />
</intent-filter>
and it doesn’t seem to work, I clicked on a link in a text that went to http://www.ex-ample.com/test/123 and it just opened in a browser.
I’m really wondering two things:
- can you use a mineType and a host/scheme attribute together
- can you see anything else wrong with this?
Yes, at least according to the docs on
<data>.If http://www.ex-ample.com/test/123 does not return a document of MIME type
vnd.android.cursor.item/vnd.example.cragon an HTTP HEAD request, your<intent-filter>will not match.