本文介绍了如何从我的应用程序中打开标准的谷歌地图应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序的用户presses按钮,我想打开标准的谷歌地图应用程序,以显示特定位置。我该怎么办呢? (不使用 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:
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的:地理:?0,0 Q =地址
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
这篇关于如何从我的应用程序中打开标准的谷歌地图应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!