You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android画中画窗口首次启动其他应用时自动关闭问题

Android画中画(PIP)首次启动其他应用时自动关闭问题

问题现象

  • 画中画窗口在首次启动任意其他应用时自动关闭;若已有其他应用处于打开状态,则不会出现该问题
  • 该功能在Android 10上运行正常,高版本Android出现异常

现有配置

AndroidManifest.xml 配置

<activity
    android:name="xxxx"
    android:label="@string/xxxx"
    android:exported="false"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode|smallestScreenSize|screenLayout"
    android:screenOrientation="portrait"
    android:supportsPictureInPicture="true"
    android:theme="@style/Theme_NewApp"
    android:resizeableActivity="false"
    android:launchMode="singleTask"
>

画中画参数配置

return PictureInPictureParams.Builder()
    .setAspectRatio(Rational(144, 224))
    .build();

错误日志现象

  • 首先触发Activity的onStop方法,随后PIP窗口关闭
  • 伴随错误日志:

ActivityManager: Unable to launch app [目标应用包名/类名] for intent [具体Intent信息]: process is bad

解决方案尝试

  • 调整启动模式:将launchMode="singleTask"改为singleTop或默认的standard,singleTask的栈管理逻辑可能在高版本Android中与PIP窗口机制冲突。
  • 移除resizeableActivity配置:删除android:resizeableActivity="false",高版本Android中PIP功能依赖窗口可调整特性,该配置可能导致系统无法正确维持PIP窗口。
  • 检查生命周期回调:确保onStop方法中没有主动关闭PIP的逻辑,同时正确实现onPictureInPictureModeChanged回调,避免切换模式时意外终止窗口。
  • 验证宽高比:尝试使用系统标准宽高比(如16:9、4:3)替换Rational(144,224),非标准比例可能触发系统窗口管理的异常逻辑。
  • 检查组件导出配置:确认与PIP相关的组件(如媒体会话服务)导出配置正确,避免系统无法与应用正常交互。

内容的提问来源于stack exchange,提问作者Chetan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 07:55:26