我在找到答案之后创建了这个问题,我不确定礼仪,但它seems to be OK(另外,我现在看到有一个内置选项)。
问题如标题所述,我们使用类似于此的代码创建了一个意图选择器:
String url = "waze://?ll=" + latitude + ", " + longitude + "&navigate=yes";
Intent intentWaze = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
String uriGoogle = "google.navigation:q=" + latitude + "," + longitude;
Intent intentGoogleNav = new Intent(Intent.ACTION_VIEW, Uri.parse(uriGoogle));
String title = context.getString(R.string.title);
Intent chooserIntent = Intent.createChooser(intentGoogleNav, title);
Intent[] arr = new Intent[1];
arr[0] = intentWaze;
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, arr);
context.startActivity(chooserIntent);
获得两个Waze图标和一个Google Maps图标;更糟糕的是,其中一个Waze图标没有启动导航(只打开应用程序)。
我们无法use the geo:
意图,因为我们需要控制显示的意图(我们不想一直显示两个意图)和Google地图中的导航类型(例如:&mode=w
)。
答案 0 :(得分:11)
一段时间后,我使用了解决方案found here,并且只有一个图标正常工作。正如我在问题中所写,我无法使用此解决方案,因为它缺乏我需要的灵活性,因此在查看代码后,我看到缺少的是:
intentWaze.setPackage("com.waze");
// and more importantly, this:
intentGoogleNav.setPackage("com.google.android.apps.maps");
似乎Waze正在聆听谷歌地图的意图(并且不能很好地使用它),这就是为什么有两个图标。