Google Maps Activity

One of the applications that comes with Android is Google Maps itself. If it's appropriate, you can start Google Maps from your application the same way you start any other Activity:

Create an Intent (new Intent(String action, Uri uri)) that says you need to display a Map. The parameters are:

An action, for which you must specify ACTION_VIEW.

A Uri, for which you should specify one of the following URI Schemes, substituting your data:

  • geo:latitude,longitude
  • geo:latitude,longitude?z=zoom
  • geo:0,0?q=my_street_address
  • geo:0,0?q=business_near_city

Call startActivity(Intent intent), using the Intent you just created.

An example that creates a map is:

  1. Intent intent = new Intent(ACTION_VIEW, "geo:47.677183,17.633877");
  2. startActivity(intent);

This is certainly easy, and gets you all the power of Google Maps, but you can't really integrate the map into your application this way. Google Maps is an application unto itself, and there's no way for you to change anything about the user interface or add overlay graphics to the map to point out whatever is of interest to your users. Android provides more flexible packages to add that power.
Mobile Phone Handheld Hardware Hardware Rick Rogers John Lombardo O'Reilly Media, Inc. O'Reilly Media Android Application Development, 1st Edition