在找到答案之后,我提出了这个问题,我不确定礼仪,但它是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图标;更糟糕的是,其中一个Waze图标没有启动导航(只打开应用程序)。
我们不能geo:意图,因为我们需要控制显示的意图(我们不想在任何时候都显示意图)和Google中的导航类型(例如:&mode=w)。
发布于 2017-11-16 09:13:49
过了一段时间,我使用了解决方案found here,只有一个图标正常工作。正如我在问题中所写的,我不能使用这个解决方案,因为它缺乏我所需的灵活性,所以在查看代码之后,我发现缺少的是:
intentWaze.setPackage("com.waze");
// and more importantly, this:
intentGoogleNav.setPackage("com.google.android.apps.maps");看起来Waze在听Google的意图(而且不能很好地使用它),这就是为什么有两个图标。
https://stackoverflow.com/questions/47325631
复制相似问题