【问题标题】:PendingIntent on Notification starting a new of the same ActivityPendingIntent on Notification 开始一个新的相同活动
【发布时间】:2014-07-28 18:31:16
【问题描述】:

如果Activity 已经启动,我希望将PendingIntent 设置为Notification 不启动新的Activity(也不将其添加到后堆栈)

我应该遗漏一些东西,因为我尝试了 Prevent notification PendingIntent starts Activity already started?Android: new Intent() starts new instance with android:launchMode="singleTop"Android notification bar open last active activity?,但它们都不起作用。

如何做到这一点?

【问题讨论】:

    标签: android android-activity


    【解决方案1】:

    android:launchMode="singleTop"

    这只会停止从同一个 Activity 打开新的 Activity 实例。 eg:试图从ActivityA打开ActivityA。

    instance1 of ActivityA -> ActivityB -> instance2 of ActivityA 之类的东西仍然适用于 android:launchMode="singleTop"

    您正在试验哪种情况?

    也可以尝试android:launchMode="singleTask" 并使用onNewIntent();

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多