Suppressing Google Maps Intent Selection Dialog(禁止谷歌地图意图选择对话框)
问题描述
当我使用这段代码时
string url = "somegooglemapsurl.com";
Intent mapLauncherIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
startActivity(mapLauncherIntent);
会弹出一个选择对话框,询问我是否要在地图应用程序或浏览器中打开此地图.我希望从我的应用程序活动到 Google 地图的过渡是无缝的.如何抑制此对话框并告诉 android 在地图活动中打开地图?
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?
当我进入谷歌地图时,我想在某个位置使用公共蒸腾打开一个方向提示.我可以通过 google maps 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.
推荐答案
我还没有找到完美的解决方案,但这至少可以打开预先选择正确目的地和公共交通的地图.然后用户所要做的就是点击方向按钮.
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.
它还会检查是否安装了谷歌地图,如果安装了,则更喜欢使用它.
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;
}
这篇关于禁止谷歌地图意图选择对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:禁止谷歌地图意图选择对话框
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01