如何使用填充的堆栈开始活动? [英] How to start activity with populated backstack?

查看:71
本文介绍了如何使用填充的堆栈开始活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一条需要启动活动B的通知.但是,我希望能够让用户返回"到Dasboard A.

I have a notification that needs to start a activity B. However, I want to be able to let the user "go back" to the Dasboard A.

我想知道如何做到这一点?我是否需要使用额外的意图来启动A并在onCreate中处理该意图,然后手动启动B?还是可以手动指定后退堆栈?

I am wondering how this could be done? Will I need to use a intent extra to start A and process that intent in onCreate and then start B manually? Or is it possible to manually specify a backstack?

推荐答案

我将使用您自己的解决方案,并为活动A创建一个Intent,并以某种方式告诉活动A该活动A应该启动活动B.

I would go with your own solution and create an Intent to activity A and somehow tell activity A in this Intent that it should start Activity B.

此行为不是标准的Android行为.应该使用返回按钮使用户进入最后一个屏幕.我不会尝试劫持此操作系统功能.

This behavior is not the standard Android behavior. The user should be used to get to the last screen with the back button. I would not try to hijack this Operating System feature.

如果在您的情况下,例如,通过通知将用户发送到消息的详细信息视图,则back应该关闭您的应用并返回上一个屏幕.如果您想让用户有可能从消息退回"到整个消息收件箱,请使用向上导航结构,可与ICS操作栏一起使用.听起来很复杂,但从本质上讲,这仅意味着您需要添加一个将用户带到收件箱的按钮.自从引入操作栏(我认为是2010年夏季)以来,此向上按钮就处于标准位置.它在屏幕的左上角. (就像iOS的后退按钮;))

If in your case the user for example is sent to a detailview of a message through the notification, back should close your app and move back to the previous screen. If you want to give your user the possibility to go "back" from the message to the overall message inbox, use the up navigation structure that can be used with the ICS Action Bar. Sounds complicated but in the essence it only means that you need to add a Button that takes the user to the Inbox. Since the introduction of the Actionbar (Summer 2010 I think) there is a standard position for this up button. It is in the upper left corner of the screen. (just like the iOS back button ;) )

这篇关于如何使用填充的堆栈开始活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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