【问题标题】:Navigation with Waze and Google Maps using Intent.createChooser shows Waze icon twice使用 Intent.createChooser 使用 Waze 和 Google Maps 进行导航显示 Waze 图标两次
【发布时间】:2018-04-29 18:05:26
【问题描述】:

我在找到答案后创建了这个问题,我不确定礼仪,但它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);

还有两个位智图标和一个谷歌地图图标;更糟糕的是,其中一个位智图标没有启动导航(仅打开应用程序)。

我们不能use the geo:intent,因为我们需要控制显示的intent(我们不想一直显示这两种intent)和谷歌地图中的导航类型(例如:&mode=w)。

【问题讨论】:

    标签: android google-maps android-intent-chooser waze


    【解决方案1】:

    一段时间后,我使用了解决方案found here,只有一个图标正常工作。正如我在问题中所写,我无法使用此解决方案,因为它缺乏我需要的灵活性,所以在查看代码后,我发现缺少的是:

    intentWaze.setPackage("com.waze");
    // and more importantly, this:
    intentGoogleNav.setPackage("com.google.android.apps.maps");
    

    Waze 似乎在听 Google Maps 的意图(并且不能很好地使用它),这就是为什么有两个图标。

    【讨论】:

    • 这太棒了。
    猜你喜欢
    • 2018-05-09
    • 2012-02-23
    • 2020-12-29
    • 2018-11-18
    • 2018-07-17
    • 2014-10-29
    • 2018-05-21
    • 1970-01-01
    • 2019-06-05
    相关资源
    最近更新 更多