Can you use android intents to listen for a hyperlink click?
I run a website similar to rotten-tomatoes that allows users to add their reviews for movies. I am currently developing an app for android that allows users to post their reviews directly from their phone and providing a wiki or imdb link for the title is a very important part of the process.
Is there a way (I'm assuming with intents) to either monitor the android's clipboard or listen for a link press and only subscribe my application to run for imdb.com links? (Obviously this will be a optional pref开发者_运维技巧erence in the app.) And what would be the best way to approach this without wasting battery life?
Or is there another approach to achieve this?
This isn't easily searchable, so hopefully this helps people out in the future. Adding this to the AndroidManifest.xml file is how to use intent filters to get your app on the list of handlers for a hyperlink:
<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.imdb.com" android:scheme="http" />
</intent-filter>
Of course, alter the android:host to match which site you want to catch. You can also use the android:pathPrefix
精彩评论