我在按下后退按钮时以 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/