燮pressing谷歌地图意图选择对话框 [英] Suppressing Google Maps Intent Selection Dialog
问题描述
当我使用这个code
When I use this code
string url = "somegooglemapsurl.com";
Intent mapLauncherIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
startActivity(mapLauncherIntent);
一个选择弹出对话框,询问我是否要打开此地图中的地图应用程序或浏览器。我想从我的应用程序的活动,以谷歌地图的转换是无缝的。我怎样才能晚饭preSS此对话框,告诉机器人在活动地图打开地图?
A selection dialog pops up asking if I want to open this map in the maps application or the browser. I'd like the transition from my application activity to Google Maps to be seamless. How can I suppress this dialog and tell android to open the map in the maps activity?
编辑:当我进入谷歌地图我想开一个方向使用公共蒸腾在某个位置提示。我可以通过谷歌地图的URL做到这一点,但一个URL会弹出选择对话框。
When I get into Google Maps I want to open a directions prompt using public transpiration in a certain location. I can do this through a google maps url, but a url brings up the selection dialog.
推荐答案
我还没有找到一个完美的解决方案,但是这将至少开放与正确的目标和公共交通pre-选择地图。然后,所有用户所要做的就是打方向按钮。
I haven't found a perfect solution, but this will at least open maps with the correct destination and public transportation pre-selected. Then all the user has to do is hit the directions button.
还检查谷歌地图的安装和prefers使用,如果如此。
It also checks if google maps is installed and prefers to use that if so.
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?daddr=0,0%20(Imaginary%20Place)&dirflg=r"));
if (isAppInstalled("com.google.android.apps.maps")) {
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
}
startActivity(intent);
 
// helper function to check if Maps is installed
private boolean isAppInstalled(String uri) {
PackageManager pm = getApplicationContext().getPackageManager();
boolean app_installed = false;
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
app_installed = true;
} catch (PackageManager.NameNotFoundException e) {
app_installed = false;
}
return app_installed;
}
这篇关于燮pressing谷歌地图意图选择对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!