问题描述
我在按下回退按钮时以画中画模式播放我的视频。 一切顺利。视频播放完美。导航等 但问题是当我关闭 PIP 模式时。 在我最近的应用程序窗口中创建了新窗口。 图像。 See those white windows those are left by pip mode when i click pip mode close button.
当我关闭 pip 模式时,有什么方法可以解决这个问题并关闭活动,请帮忙..
解决方法
尝试在 configuration
中使用下面的 Manifest
来为您的 Activity
避免多个实例
<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 模式下关闭时 finish
的 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()
}
}