简体   繁体   English

如何使发布活动始终作为家庭活动

[英]How to make launch activity always as home activity

I have 3 activities in my app. 我的应用程序中有3个活动。 A is the launcher activity, when I press on a button Activity B will be started, then I have a button to start Activity A or I can press back button and I can go to A. On back press previous values retained in and on button click new values will be set on A. A是启动器活动,当我按下按钮时,活动B将启动,然后我有一个按钮来启动活动A或者我可以按下后退按钮我可以转到A.在后退按下保留在按钮上的前一个值点击新值将在A上设置。

When I click a button in B , A will be started, I am using REORDER TO FRONT flag and singletop as launch mode. 当我点击B中的一个按钮时,A将启动,我使用REORDER TO FRONT标志和singletop作为启动模式。 New activity is not getting created . 新活动未创建。 When I press back button on A it will transit to B and again I press back button app exits. 当我按下A上的后退按钮时,它将转到B并再次按下后退按钮app退出。 I want to have activity A on back press on B. I cannot do anything in onBackpressed() in B as B is used in several scenarios apart from the above mentioned scenario. 我希望在B上按下活动A.我不能在B中的onBackpressed()中做任何事情,因为除了上面提到的场景之外,B用于几种情况。 How to manage it. 如何管理它。

I have nor clearly understood what you are trying to do, but you could try the up-navigation pattern ( http://developer.android.com/design/patterns/navigation.html#up-vs-back ). 我也没有清楚地了解你想要做什么,但你可以尝试向上导航模式( http://developer.android.com/design/patterns/navigation.html#up-vs-back )。

You would have to declare in your manifest that activity A is the parent activity of B and then use NavUtils.navigateUpFromSameTask(this); 您必须在清单中声明活动A是B的父活动,然后使用NavUtils.navigateUpFromSameTask(this); in your button OnClickListener. 在按钮OnClickListener中。 (NavUtils is in the support.v4 package). (NavUtils位于support.v4包中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM