I am developing an app that can extract information from certain web pages. The idea is that when the user is within a specific url path in the browser and press the share button, my app will show up in the list of receiver apps.
I can do that easily by adding this to the manifest:
<intent-filter android:label="@string/app_name" >
<action android:name="android.intent.action.SEND" />
<data android:mimeType="text/plain" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
However, this will make my app appear on the list on all urls, also all those where it will have nothing to do. Instead I would like the app appear in the chooser only from these urls:
www.example.com/foo/bla.html
www.example.com/foo/bar/blabla.html
But not from these:
www.example.com
www.foobar.com
etc. Ie. only from within a certain path on a certain host. Also note that I do not want my app to be launched when the user clicks on links matching the criteria. It should only be invoked from the share menu.
So my question is: How can I limit my app to show up in the intent choose only for certain urls?
Add the following filter to the destination Activity .. 1. host your site name. 2. scheme scheme of your site http or https. 3. path for the file path your app should display.
<intent-filter>
<data
android:host="www.example.com"
android:scheme="http"
android:path="/foo/bla.html"
/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" >
</category>
<category android:name="android.intent.category.BROWSABLE" >
</category>
</intent-filter>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With