androidandroid-picture-in-picture

How to detect picture in popup dismissed (drag down to dismiss)?


We are using the calls page with a picture in picture(pip) feature.

Problem :
In case user dismiss the pip popup window (by drag down to dismiss) we not able to detect that. enter image description here

How to detect picture in picture window drag down to dismiss?

Update:
Set picture in picture

// RemoteRenderLayout -> call preview layout. You can set anyone view
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

    Rational aspectRatio = new Rational(
        remoteRenderLayout.getWidth(), remoteRenderLayout.getHeight());
    PictureInPictureParams params = new PictureInPictureParams.Builder()
        .setAspectRatio(aspectRatio)
        .build();
    enterPictureInPictureMode(params);
}
else{

    enterPictureInPictureMode();
}

Solution

  • When the activity enters or exits picture-in-picture mode the system calls Activity.onPictureInPictureModeChanged() or Fragment.onPictureInPictureModeChanged().

    You can implement your code inside this:

     override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean,
                                               newConfig: Configuration) {
        if (isInPictureInPictureMode) {
            // Hide the full-screen UI (controls, etc.) while in picture-in-picture mode.
        } else {
            // Restore the full-screen UI.
        }
    }