I've read about intents in android but here goes my question. I'd like to launch an app on my android phone with the click of a link in the web browser. Example: If the link is "mycam://http://camcorder.com", "mycam://" acts as some kind of "tag" to launch my app but I'd like to pass "http://camcorder.com" as a string to that app on start.
Help please!
Thanks!
mycam://http://camcorder.com isn't a valid URI, and making up schemes is kind of scary if two apps pick the same one. It would be better for you to register your activity as a handler for a particular URI (for example http://www.example.com/camcorder, substituting your own domain of course). You do that with the <data> tag in your <intent-filter> tag in the AndroidManifest.xml. When the user clicks the link, they'll be taken to your application. That way, you can also put a real page there on the web, instructing people to install your app or whatever.
There is a method in the Browser app source code, :
After a url clicked and it's not yet starting to load:
converts the url to intent
if it don't start with market:// (or some predefined schemes), try startActivityIfNeeded()
It's very useful information! I re-play the situation in some simple code:
The result will provide clues for me to write an activity with the intent-filter:
PS. don't forget the
android.intent.category.DEFAULT
.Finally, your Activity can invoke by
mycam://yourscheme
.