android - 从状态栏单击通知项时如何清除返回堆栈 Activity ?

标签 android back-stack

我正在做一个聊天项目。当从 GCM 收到推送通知时,我需要导航到聊天联系人列表并清除我的应用程序之前打开的 Activity 。

最佳答案

在 GCMIntent 服务中传递挂起的 Intent 时,需要为 Intent 设置标志。 代码如下。如果有人在这个概念上苦苦挣扎,请使用它。

PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
        new Intent(this, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | 
                Intent.FLAG_ACTIVITY_CLEAR_TASK), 0);

关于android - 从状态栏单击通知项时如何清除返回堆栈 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26023809/

相关文章:

android - 如何在操作栏中显示 EditText 时聚焦并显示软键盘?

Android:Dialog Fragment 和 Backstack 问题

android - 如何在不完成当前 Activity 的情况下返回上一个 Activity

php - Cordova 安卓 :Loading data from database with infinite scrolling in onsenui

android - 从 Android 屏幕录像机捕获的视频无法在网络浏览器上播放

android - 从 Composable 抛出异常

带左右边距的 Android 按钮

android - FLAG_ACTIVITY_NEW_TASK 和 FLAG_ACTIVITY_CLEAR_TASK 行为怪异

android - 通过 Fragments 返回后出现白屏

android - 获取 backstack 中的最新 fragment