I'm trying to implement a picture-in-picture mode in my app. I'm Implementing google map on PIP mode but I can't resize the full-screen map. It always zooms on map center point. I have done RND related to this issue but not finding any proper answer. Basically, I need the layout like Whatsapp app pip Screen on my app how to implement? And my Code is here:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

        Display display=getWindowManager().getDefaultDisplay();
        Point size=new Point();
        display.getSize(size);
        int width=size.x;
        int height=size.y;
        Rational aspectRatio=new Rational(width,height);
        PictureInPictureParams params = new PictureInPictureParams.Builder()
                .setAspectRatio(aspectRatio).build();
        enterPictureInPictureMode(params);
    }

and here is Manifest code:

<activity android:name=".activities.MainActivity"
        android:supportsPictureInPicture="true"
        android:resizeableActivity="true"
        android:launchMode="singleTask"
        android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"/>

In this code, I have the screen like

enter image description here

and I want

enter image description here

How can I solve this?

Thanks in advance!!

1 Answers

1
Mohit Lakhanpal On Best Solutions

Just Change Your this code

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

    Display display=getWindowManager().getDefaultDisplay();
    Point size=new Point();
    display.getSize(size);
    int width=size.x;
    int height=size.y;
    Rational aspectRatio=new Rational(width,height);
    PictureInPictureParams params = new PictureInPictureParams.Builder()
            .setAspectRatio(aspectRatio).build();
    enterPictureInPictureMode(params);
}

To

Rational aspectRatio = new Rational(3, 4);

        PictureInPictureParams params = new PictureInPictureParams.Builder()
                .setAspectRatio(aspectRatio).build();
        enterPictureInPictureMode(params);