Skip to content

Instantly share code, notes, and snippets.

@mahmoudmagdi
Forked from mitchtabian/GoogleMaps.java
Created June 23, 2019 13:24
Show Gist options
  • Save mahmoudmagdi/88e67ee59e6a38ff29d4c11a45ed209c to your computer and use it in GitHub Desktop.
Save mahmoudmagdi/88e67ee59e6a38ff29d4c11a45ed209c to your computer and use it in GitHub Desktop.
Launch Google maps app and get directions
String latitude = String.valueOf(49.08);
String longitude = String.valueOf(122.45);
Uri gmmIntentUri = Uri.parse("google.navigation:q=" + latitude + "," + longitude);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
try{
if (mapIntent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivity(mapIntent);
}
}catch (NullPointerException e){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment