Android Studio AndroidStudio 4说enterPictureInPicture从API 26开始就被废除了-这是不正确的,对吗?

yiytaume  于 2023-05-01  发布在  Android
关注(0)|答案(2)|浏览(178)

AndroidStudio屏幕截图显示警告:

here是:

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.

我找不到这个现在被废弃的地方。是我错过了什么,还是我错了?我想确定我的程序没有死。

ulydmbyx

ulydmbyx1#

enterPictureInPictureMode()在API 24中引入,在API 26中弃用。它已被API 26中引入的enterPictureInPictureMode(PictureInPictureParams)所取代。
此处的文档:https://developer.android.com/reference/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)

c6ubokkw

c6ubokkw2#

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);

}

相关问题