Android的 - 通知待定意图 - 添加到活动堆栈问题顶部 [英] Android - Notification Pending Intent - Add to top of activity stack issue

查看:286
本文介绍了Android的 - 通知待定意图 - 添加到活动堆栈问题顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点困惑与通知中的建设者挂起的意图。我有一个 MainActivity 活动和将MessageList 活动。我有一个服务表现出通知时发现一个新的消息,我希望它是,如果用户presses它打开到将MessageList 活动的通知但是当他们preSS回来,他们将返回到他们的活动。

I'm a bit confused with pending intents in the notification builder. I've got a MainActivity activity and a MessageList activity. I have a service to show a notification when a new message in found, and I want it to be that if the user presses the notification it opens to the MessageList activity but when they press back they will return to the activity they were in.

实质上欲 MessageList中活动添加到活动堆栈的顶部,当他们preSS的通知而不修改当前活动堆栈。

Essentially I want to add MessageList activity to the top of the activity stack when they press the notification without modifying the current activity stack.

感谢您

推荐答案

好了,所以我把它与一些老code,我写了一段时间回来工作。这确实是我想要的 -

Okay, so I got it to work with some old code I wrote a while back. This does what I wanted -

Intent notificationIntent = new Intent(this, AlertListActivity.class);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

mBuilder.setContentIntent(contentIntent);

这篇关于Android的 - 通知待定意图 - 添加到活动堆栈问题顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆