Created
December 21, 2016 16:49
-
-
Save kryjex/509c7aaf618127fc0e89d15091e4c2d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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