如何从我的应用程序打开标准的 Google 地图应用程序? [英] How to open standard Google Map application from my application?

查看:25
本文介绍了如何从我的应用程序打开标准的 Google 地图应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户在我的应用程序中按下按钮后,我想打开标准的 Google 地图应用程序并显示特定位置.我该怎么做?(不使用 com.google.android.maps.MapView)

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.google.android.maps.MapView)

推荐答案

您应该创建一个带有地理 URI 的 Intent 对象:

You should create an Intent object with a geo-URI:

String uri = String.format(Locale.ENGLISH, "geo:%f,%f", latitude, longitude);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
context.startActivity(intent);

如果你想指定一个地址,你应该使用另一种形式的地理 URI:geo:0,0?q=address.

If you want to specify an address, you should use another form of geo-URI: geo:0,0?q=address.

参考:https://developer.android.com/guide/components/intents-common.html#Maps

这篇关于如何从我的应用程序打开标准的 Google 地图应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆