简体   繁体   English

以图片和图片模式打开谷歌地图导航

[英]Open Google Maps navigation in Picture and Picture Mode

I have a simple intent to run google maps navigation - it works really well.我有一个简单的意图来运行谷歌地图导航 - 它工作得非常好。 It automatically switches to bicycle mode and does not require any confirmation from user, just starts navigating.它会自动切换到自行车模式,不需要用户的任何确认,只需开始导航。 My code looks like this:我的代码如下所示:

    try {
        Uri gmmIntentUri = Uri.parse("google.navigation:q=" + lastPoint.latitude + "," + lastPoint.longitude + "&mode=b");
        Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
        mapIntent.setPackage("com.google.android.apps.maps");
        startActivity(mapIntent);
    } catch (Exception e) {
        e.printStackTrace();
    }

Now, how can I modify this intent to run navigation in picture-in-picture mode by default (ofc it must be available in the system and enabled for google maps app)?现在,如何修改此意图以在默认情况下以画中画模式运行导航(它必须在系统中可用并为谷歌地图应用程序启用)? My app does not use PiP by itself, if it's your concern.如果您担心的话,我的应用程序本身不会使用 PiP。

You can refer this official guide PiP Support你可以参考这个官方指南PiP 支持

As shown in the article, First you may need to declare PiP support in androidmanifest.xml like this如文章所示,首先您可能需要像这样在androidmanifest.xml 中声明PiP 支持

<activity android:name="VideoActivity"
android:supportsPictureInPicture="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"

and then接着

@Override
public void onActionClicked(Action action) {
  if (action.getId() == R.id.lb_control_picture_in_picture) {
    getActivity().enterPictureInPictureMode();
    return;
  }
  ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM