Skip to content

Instantly share code, notes, and snippets.

@kryjex
Created December 21, 2016 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kryjex/509c7aaf618127fc0e89d15091e4c2d1 to your computer and use it in GitHub Desktop.
Save kryjex/509c7aaf618127fc0e89d15091e4c2d1 to your computer and use it in GitHub Desktop.
public void GoToGMaps(View view){
Intent intent = null;
String ubicacionlng = "37.7749";
String ubicacionlat = "-122.4194";
try {
// Revisa si GMaps app está instalada, luego muestra la coordenada "37.7749,-122.4194"
this.getPackageManager().getPackageInfo("com.google.android.apps.maps", 0);
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + ubicacionlat + "," + ubicacionlng));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
} catch (Exception e) {
// Si no está instalada, usa browser
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://maps.google.com/maps?z=12&t=m&q=loc:" + ubicacionlat + "+" + ubicacionlng));
}
this.startActivity(intent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment