简体   繁体   中英

How to make launch activity always as home activity

I have 3 activities in my app. 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.

When I click a button in B , A will be started, I am using REORDER TO FRONT flag and singletop as launch mode. 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. 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. 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 ).

You would have to declare in your manifest that activity A is the parent activity of B and then use NavUtils.navigateUpFromSameTask(this); in your button OnClickListener. (NavUtils is in the support.v4 package).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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