【问题标题】:Activity has leaked window while using PiP活动在使用画中画时泄漏了窗口
【发布时间】:2021-06-16 04:58:56
【问题描述】:

我的应用使用 exoplayer 显示视频流。在我使用/激活 Pip 之前,一切正常。在我将任何视频放入 Pip 并从后台堆栈返回上一个活动后(自动),当我按下任何按钮时,我得到:

WindowManager: android.view.WindowLeaked: Activity com.rcsrds.player.ui.main.MainActivity has leaked window DecorView@ff7d496[] that was originally added here

我在部分测试手机上收到此错误消息,但不是全部。如果我在 5 秒后按下任何按钮超过 1 次,我会得到 ANR(有时);我的应用不使用任何对话框

我确实有一个 ProgressBar。评论它,错误仍然出现。

LE:我的播放器是自定义视图。这应该是画中画的问题?

输入我使用的 Pip

   public void enterPictureInPicture(PictureInPictureParams nPipParams) {
       ActivityUtils.hideSystemUI(this.getWindow());
       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
           enterPictureInPictureMode(nPipParams);
       } else {
           //Toast.makeText(this,"Picture in Picture not availabe",Toast.LENGTH_LONG).show();
       }
   }

<activity
           android:name=".ui.main.MainActivity"
           android:configChanges="screenSize|smallestScreenSize|screenLayout"
           android:supportsPictureInPicture="true"
           android:excludeFromRecents="true"
           android:autoRemoveFromRecents="true"
          />




【问题讨论】:

    标签: android android-picture-in-picture


    【解决方案1】:

    您缺少android:configChanges orientation 的推荐:

    https://developer.android.com/guide/topics/ui/picture-in-picture#declaring

    完整列表应该是。 android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"

    PIP 不支持销毁 Activity。

    您的 Activity 正在被破坏,因为它以纵向运行并且输入 PIP 会将其切换为横向。

    也许您测试设备的其他时间已经在横向。

    【讨论】:

      猜你喜欢
      • 2017-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-24
      • 2016-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多