Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Latest commit

 

History

History

launch_the_map_application

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
id title brief article sdk
1BB89467-078D-32F0-58E9-4347D9A719FD
Launch the Map Application
This recipe shows how to launch the maps application at a specified location.
title url
Invoking Google Applications on Android Devices

Recipe

  1. Create a new Xamarin.Android application. The project template will create a single activity named Activity1 (MainActivity.cs), which contains a button.
  2. From the button.Click handler in MainActivity.cs, create a geo Uri with a latitude and longitude, passing the Uri to an intent.
intent.button.Click += delegate {
       var geoUri = Android.Net.Uri.Parse ("geo:42.374260,-71.120824");
       var mapIntent = new Intent (Intent.ActionView, geoUri);
       StartActivity (mapIntent);
};

Calling StartActivity and passing it the Intent in the above code launches the maps app.

Additional Information

Each screen in an application is represented by an activity. Using asynchronous messages called intents, when created from a Uri, causes the system to load an activity that can handle the Uri scheme. In this recipe a Uri beginning with geo: loads an activity from the maps application at the location specified. See the Geo Uri Scheme section in the Maps and Location article for the various formats supported by this scheme.