How to open standard Google Map application from my application?

后端 未结 9 939
星月不相逢
星月不相逢 2020-11-28 01:09

Once user presses button in my application, I would like to open standard Google Map application and to show particular location. How can I do it? (without using com.g

9条回答
  •  遥遥无期
    2020-11-28 02:06

    You can also use the code snippet below, with this manner the existence of google maps is checked before the intent is started.

    Uri gmmIntentUri = Uri.parse(String.format(Locale.ENGLISH,"geo:%f,%f", latitude, longitude));
    Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
    mapIntent.setPackage("com.google.android.apps.maps");
    if (mapIntent.resolveActivity(getPackageManager()) != null) {
        startActivity(mapIntent);
    }
    

    Reference: https://developers.google.com/maps/documentation/android-api/intents

提交回复
热议问题