preserve回活动的同时单击通知 [英] Preserve back activity while clicking notification

查看:163
本文介绍了preserve回活动的同时单击通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是这样的:当我pressing我得到了通知,有些活动是开放的,可以说活动3号。但是,当我preSS后退按钮,我的机器人来导航菜单。我想要做的是preserve用户正确的导航体验,当我pressing后退按钮它会带我去活动2号,当我pressing有在后面的按钮,它会带我去的活动编号为1,依此类推。结果
我还有一个问题是,当我打开活动2号,我需要设置有一些额外的数据的意图,但我不知道如何设置它。结果
我的问题研究综述:preserve用户的正确导航,并设置了活动,这将是由后退按钮点击打开一些额外的。

My problem is like that: When I'm pressing the notification i got, some activity is open, lets say activity number 3. But when I press the back button, I navigated by the android to the menu. What I want to do is to preserve the correct navigation experience of the user, and when I'm pressing the back button it will take me to activity number 2, and when I'm pressing there on the back button, it will take me to activity number 1, and so on.
Another problem I have is that, when I'm opening activity number 2, I need to set there some extra data in the intent, but I don't know how to set it.
Summery of my problem: preserve the correct navigation of the user and set some extras for the activity that will be open by the back button click.

下面是我的通知code:

Here is my notification code:

NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.ic_launcher)
                .setContentTitle("New Question")
                .setContentText("" + CurrentQuestion.getAuthor().getUserName() + ": " + CurrentQuestion.getQuestion() + "");

        Intent openHomePageActivity = new Intent("com.example.ihelp.HOMEPAGEACTIVITY");
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        stackBuilder.addNextIntent(openHomePageActivity);
        PendingIntent resultPendingIntent =
                stackBuilder.getPendingIntent(
                    0,
                    PendingIntent.FLAG_UPDATE_CURRENT
                );
        mBuilder.setContentIntent(resultPendingIntent);
        NotificationManager mNotificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(0, mBuilder.build());

谢谢!

推荐答案

看起来像要合成一回堆栈:<一href=\"http://developer.android.com/training/implementing-navigation/temporal.html#SynthesizeBackStack\" rel=\"nofollow\">http://developer.android.com/training/implementing-navigation/temporal.html#SynthesizeBackStack (请参阅创建回栈开始活动时)

Looks like you want to synthesize a back stack: http://developer.android.com/training/implementing-navigation/temporal.html#SynthesizeBackStack (see "Create back stack when starting the activity")

和也<一个href=\"http://developer.android.com/guide/topics/ui/notifiers/notifications.html#NotificationResponse\" rel=\"nofollow\">http://developer.android.com/guide/topics/ui/notifiers/notifications.html#NotificationResponse (作为常规活动启动活动时preserving导航)

and also http://developer.android.com/guide/topics/ui/notifiers/notifications.html#NotificationResponse ("Preserving Navigation when Starting an Activity" as a "Regular activity")

这篇关于preserve回活动的同时单击通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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