【问题标题】:Push notification click using TaskStackBuilder使用 TaskStackBuilder 推送通知点击
【发布时间】:2016-07-20 08:40:59
【问题描述】:

我正在将 Receiver 活动设置为通知的内容意图。

Intent clickIntent = new Intent(context, Receiver.class);
            mBuilder.setContentIntent(PendingIntent.getActivity(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT));

在 Receiver Activity 中,我正在启动旨在通过以下方式使用 TaskStackBuilder 打开的活动。

Intent intent = new Intent(this, Class.forName(className));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
       TaskStackBuilder.create(this).addParentStack(Class.forName(className)).addNextIntent(intent).startActivities();

当应用程序在后台并且发生通知点击时,它会恢复 ParentActivity。特别是当设备进入空闲状态并返回时。有什么帮助吗?我对此感到头疼。

【问题讨论】:

    标签: google-cloud-messaging taskstackbuilder


    【解决方案1】:

    对于 Android 应用,您还应该在 androidManifest.xml 文件中声明 android:launchMode

    Android documentation中所述:

    关于如何启动活动的说明。有四种模式与Intent 对象中的活动标志(FLAG_ACTIVITY_* 常量)一起工作,以确定当调用活动来处理意图时应该发生什么。

    他们是:

    • “标准”
    • “单顶”
    • “单任务”
    • “单一实例”

    默认模式是“标准”。

    此 SO 帖子中给出的解决方案 - resuming an activity from a notification 也可能有所帮助。

    【讨论】:

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