Reputation: 159
I have a problem to let Google Maps playing automatically after opened...
Example: I have put intent code and yes it will open Google maps according to my latitude and longitude... But, I still need to press a button to start Google Maps to direct me. How can I make Google Map open automatically after opened by intent without pressed by users? Is it possible ?
Here is my code,
private void turnOnMap()
{
String labelMap = "Target";
String geouri = "geo:0,0?q=-6.908572,107.610923(XXI)";
Intent mapInt = new Intent(Intent.ACTION_VIEW, Uri.parse(geouri));
startActivity(mapInt);
}
I got some information of intent code from these open google maps through intent for specific location in android and Android - How to launch Google map intent in android app with certain location, zoom level and marker and also latest uri from official android site https://developer.android.com/guide/components/intents-common.html#Maps
And, they don't explain what command should I add to play Google Maps automatically after opened...
Hope you can help me guys... Thank you very much for your time and information
Upvotes: 2
Views: 9178
Reputation: 3920
String strUri = "http://maps.google.com/maps?q=loc:" + latitude + "," + longitude + " (" + yourLocationName + ")";
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(strUri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
Upvotes: 12