我想以明确的意图从我的应用启动Google Maps;我不想导航到地图上的某个点或不想在地图上显示任何特定的地方-我只想启动Google地图。
我该怎么做?有什么目的?
答案 0 :(得分:1)
使用以下代码
String uri = "http://maps.google.com/";
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
它将打开 Google Map 应用程序。
答案 1 :(得分:1)
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Uri gmmIntentUri = Uri.parse("geo:0,0?q=");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
}
}, 1000);
在单击按钮或您要实现的任何其他位置中使用上面的代码。