Android - Is this possible? Different Intent based on what apps are installed
I have an app that uses maps. I want to give the user the choice to pick their own maps application, eg Google Maps, MapDroyd, OR give them the option to open in a Browser.
However, instead of going to maps.google.com/....
or whatever the site is, I currently have it going to mysite.com/find.php?lat=123.456&lon=456.789
.
So, I want a list 开发者_StackOverflow社区of suitable apps to pop up and if they click the browser
go to mysite.com...
, if they click Google Maps
launch an intent with geo:123.456,567,890
and likewise if they have MapDroyd
installed.
This will also depend on whether or not they have the apps installed in the first place! I suppose the easiest way is to just use the geo:
intent but then the browser URL will be Googles URL and not my own!
So, is it possible to alter the default Google Maps URL when the browser is selected?
Thanks for any help.
So, is it possible to alter the default Google Maps URL when the browser is selected?
No.
So, I want a list of suitable apps to pop up
Use PackageManager
and queryIntentActivities()
for each distinct Intent
you would want to use. Combine the results (use a HashSet
or otherwise net out anything that responds to both Intents
). Display the results in a dialog.
This sample project demonstrates using queryIntentActivities()
and launching activities based on a chosen result. It does not handle your multiple possible Intents
nor uses a dialog.
精彩评论