views:

675

answers:

1

hi all,

i have an address for a location. when i click some button in my app. it should redirect to default google map in android and drop the pin to that particular location. how to do that? Any Idea?

+4  A: 

The Android documentation describes the various Intents that the Google Maps application will respond to, if it exists on a given device. You will presumably want a geo:0,0?q=my+street+address Uri on an ACTION_VIEW Intent.

CommonsWare
is this possible in emulator?
Praveen Chandrasekaran
As far as I know, yes. Certainly `geo:` `Uri` values work on the emulator, though I have only tried the flavor where you supply a latitude and longitude. I have not tried using geolocation via an address.
CommonsWare
can you tell me the syntax plz. i cant do that.
Praveen Chandrasekaran
`"geo:0,0?q=my+street+address"` is a String, where you replace `my+street+address` with your address in URL-encoded form. You use `Uri.parse()` to turn it into a `Uri`. You pass that as the second parameter to an Intent constructor that take `ACTION_VIEW` as the first parameter. You wrap all of that in a `startActivity()` call. See http://github.com/commonsguy/cw-android/tree/master/Activities/Launch/ for a sample project (but one that uses the latitude/longitude form of the `Uri`).
CommonsWare