Reputation: 86
navigation button not visible when we call the navigation intent with own credential in google map android.
This is my code that i call in my activity.
public void NavigatePath(){
Uri gmmIntentUri = Uri.parse("http://maps.google.com/maps?" + "saddr=" + Sourcelat + "," + Sourcelong + "&daddr=" + Destinationlat + "," + Destinationlong);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
}
Please recommend me how to visible navigation button.
Upvotes: 0
Views: 245
Reputation: 2576
i am using this, and it working perfectly:
String uri = String.format(Locale.ENGLISH, "http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", sourceLatitude, sourceLongitude, destinationLatitude, destinationLongitude);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
try
{
startActivity(intent);
}
catch(ActivityNotFoundException ex)
{
try
{
Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(unrestrictedIntent);
}
catch(ActivityNotFoundException innerEx)
{
Toast.makeText(this, "Please install google maps application!", Toast.LENGTH_LONG).show();
}
}
Upvotes: 1