android - 从画中画窗口中打开的通知启动 Intent

标签 android android-intent android-pendingintent android-picture-in-picture

我关注了 Android picture-in-picture documentation .也就是说,我的画中画 Activity 被标记为android:launchMode="singleTask"android:resizeableActivity="true",和android:configChanges="screenSize |smallestScreenSize|screenLayout|orientation” 在 list 中。

画中画似乎效果很好。但是,我注意到我遇到了不良行为。

当我的应用程序收到推送时,我创建了一个 PendingIntent,其中包含 MyActivityIntent(不同的 Activity比 PiP Activity)。但是,当我点击通知并使用 Intent 时,MyActivity 会在 PiP 窗口内启动!

我已经尝试将 android:launchMode="singleTask" 添加到 list 中的 MyActivity 中。在与 PendingIntent.getActivity() 一起使用之前,我还尝试以编程方式将该标志添加到 Intent。这似乎无法解决问题。

谁能告诉我如何防止这种情况发生?

最佳答案

为了解决这个问题,我们应该为 list 中的 PiP Activity 设置一个唯一的 taskAffinity。它指示 Activity 所属的任务。为它设置一个唯一的值将 PiP Activity 的任务与 MainActivity 分开。

<activity
    android:name=".VideoActivity"
    android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
    android:taskAffinity=".VideoActivity"
    android:supportsPictureInPicture="true" />


---------------------- 之前 ------------------ ---------------------- 之后 -------------- --------

enter image description here enter image description here

关于android - 从画中画窗口中打开的通知启动 Intent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54028535/

相关文章:

android - 隐藏可穿戴设备上的打开电话操作

android - 为通知的未决 Intent 设置不同的 Activity

android - 与 Android Studio 相关的 build.gradle 文件中无法访问的几个任务

java - 如何使用 Firebase 1.0.2 忽略对象模型的新字段

android - 钛: Intent 后的新观点

android - 如何在我的应用程序中访问 gmail 附件数据

java.lang.RuntimeException : Failure delivering result ResultInfo{who=null, request=131074,结果=-1,data=Intent {(有额外内容)}}到 Activity

android - 通过警报管理器在特定时间创建通知

android - 如何显示android数字键盘?

Android ImageView 设置位图 FitXY 不起作用