Intent
Intents let you start an activity in another app by describing a simple action you'd like to perform (such as "display a map" or "show directions to the airport") in an Intent object. The Google Maps app for Android supports several different intents, allowing you to launch the Google Maps app and perform one of four actions:
- Display a map at a specified location and zoom level.
- Search for locations or places, and display them on a map.
- Request directions from one location to another. Directions can be returned for three modes of transportation: driving, walking, bicycling.
- Display panorama imagery in Google Street View.
This page describes the intents that you can use with Google Maps app for Android. For more information on Intents and Intent Filters, or Intents common to the Android platform, refer to the Android developer documentation.
Intent requests
In order to launch Google Maps with an intent you must first create an
Intent object, specifying its action, URI and package.- Action: All Google Maps intents are called as a View action —
ACTION_VIEW. - URI: Google Maps intents use URI encoded strings that specify a desired action, along with some data with which to perform the action.
- Package: Calling
setPackage("com.google.android.apps.maps")will ensure that the Google Maps app for Android handles the Intent. If the package isn't set, the system will determine which apps can handle theIntent. If multiple apps are available, the user may be asked which app they would like to use.
Open map apps through intent
Procedure:
1. Create a new project and open it.
2. Add edit text and button to your view
3. Create a string variable named (name).
4. Add the string block and ASD block to On click event showed in the diagram(follow the diagram).
4. Add this code to your ASD block.
Code:
intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(name));
intent.setPackage("com.google.android.apps.maps");
startActivity(intent);
5. Run Your app.
You can watch the video with this link:-


It work for me
ReplyDelete