AndroidStudio 4 says enterPictureInPicture is depracated as of API 26 - this is incorrect, right?

1.6k Views Asked by At

AndroidStudio screenshot showing the warning:

enter image description here

Yet what I find here is:

Android 8.0 (API level 26) allows activities to launch in picture-in-picture (PIP) mode.
PIP is a special type of multi-window mode mostly used for video playback. It lets the
user watch a video in a small window pinned to a corner of the screen while navigating
between apps or browsing content on the main screen.

Nowhere can I find where this is now depracated. Am I missing something or is AS in error? I want to be sure I'm not coding down a dead path.

2

There are 2 best solutions below

0
On BEST ANSWER

enterPictureInPictureMode() was introduced in API 24 and deprecated in API 26. It has been superseded by enterPictureInPictureMode(PictureInPictureParams), introduced in API 26.

Documentation here: https://developer.android.com/reference/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)

1
On

@Override public void onUserLeaveHint() {

   // Crear un objeto PictureInPictureParams
   PictureInPictureParams.Builder pictureInPictureParamsBuilder =
           new PictureInPictureParams.Builder();
   pictureInPictureParamsBuilder.setAspectRatio(new Rational(16, 9));
   pictureInPictureParamsBuilder.setSourceRectHint(new Rect(0, 0, 100, 100));
   PictureInPictureParams pictureInPictureParams = pictureInPictureParamsBuilder.build();

   if (isInPictureInPictureMode()) {
       return;
   }
   enterPictureInPictureMode(pictureInPictureParams);

}