android - 画中画打开应用程序的新窗口并显示大量最近的任务

标签 android android-layout picture-in-picture android-picture-in-picture

我在按下后退按钮时以 PIP 模式播放我的视频。 一切都很好。视频播放完美。导航等 但问题是当我关闭 PIP 模式时。 在我最近的应用程序窗口中创建了新窗口。 图片。 See those white windows those are left by pip mode when i click pip mode close button.

有什么办法可以解决这个问题并在我关闭 pip 模式时关闭 Activity 请帮助..

最佳答案

尝试在 Manifest 中为您的 Activity 使用以下 configuration 以避免多个实例

<activity
      android:name=".view.activities.PlayerActivity"
      android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|uiMode"
      android:excludeFromRecents="true"
      android:launchMode="singleTask"
      android:resizeableActivity="false"
      android:taskAffinity=".PlayerActivity"
      android:supportsPictureInPicture="true"
      android:windowSoftInputMode="adjustResize"
      tools:targetApi="n"/>

下面的方法是在 PIP 模式下关闭时完成 activity

var isInPipMode: Boolean = false

override fun onPictureInPictureModeChanged(
        isInPictureInPictureMode: Boolean,
        newConfig: Configuration?
    ) {
        super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
        isInPipMode = isInPictureInPictureMode
    }

 override fun onStop() {
        super.onStop()
        if(isInPipMode){
            finish()
        }
    }

关于android - 画中画打开应用程序的新窗口并显示大量最近的任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66148524/

相关文章:

android - Recyclerview 第一项开始 margin

java - 线性布局使用权重来适应屏幕尺寸

ios - 当用户选择要播放的新视频时关闭画中画视频

javascript - 我的 Web 文档中未启用画中画的可能原因是什么?

android - 如何在 android eclipse sdk 中预览 ~ 21 英寸设备的布局?

android - 多次调用 onCreateView fragment

android - 在多个 TextView 中使用时选取框不起作用

android - 如何在Android TV主屏幕上为当前正在运行的任务设置图标和标题

android - 在启动 Activity android时出错

java - 使用 SpinnerAdapter 自定义 Android Spinner XML?