android - How to show activity from activity stack -


I need some help about the activity stack.

In my app I have 6 screen users, / P>

  1 - & gt; 2 - & gt; 3 - & gt; 4 - & gt;   

When I go to 4 screens I press the cancel button

When a user clicks on that button, it should go to the second screen and

When the user clicks the back button on the keypad, it should go to 1 screen which is already in the activity stack How to do this

Please give me an example.

just use FLAG_ACTIVITY_CLEAR_TOP

when user Clicks:

  intent = intent to be new intent (activity d. This activity, B. class); Intent.addFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP); StartActivity;   

When the user presses back:

  @KeyDown public boolean override (intccode, key event) {if (keycode == KeyEvent.KEYCODE_BACK) {Intent (intent) = new intention (activity d. This, activity class); Intent.addFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent.addFlags (Intent.FLAG_ACTIVITY_SINGLE_TOP); StartActivity; } Return super.Condondon (keycode, event); }   

This code will take the user to the first activity. Activity will not be rebuilt due to FLAG_ACTIVITY_SINGLE_TOP . When activity is already on the stack then onNewIntent () will be applied in which you can use data from the intent for example.

If you want these behaviors to default for your behavior, then put the flag on Android management to the announcements.

Comments