我在找到答案后创建了这个问题,我不确定礼仪,但似乎没问题(另外,我现在看到有一个内置选项).
问题如标题中所述,我们使用类似于此的代码创建了一个意图选择器:
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);
Run Code Online (Sandbox Code Playgroud)
并获得两个Waze图标和一个Google Maps图标; 更糟糕的是,其中一个Waze图标没有启动导航(只打开应用程序).
我们无法使用geo:意图,因为我们需要控制显示的意图(我们不想一直显示两个意图)和谷歌地图中的导航类型(例如:) &mode=w.