I have 3 Activities...the first Activity have a button that start third Activity. The problem is: When I am in 3 - rd activity press "back" button its navigate me back to 1 - st Activity, but i need to 2 - nd one. My stack of Activities always should look like : 1. first Activity 2. second Activity 3. third Activity
How to do that ? Thanks...
If the 2nd activity is not on the stack - which it sounds like it isnt, because you went from 1st -> 3rd - which means that in your 3rd activity you will have to implement onKeyDown and capture the BACK key, and then start a new Intent with the 2nd activity.
You can intercept the back button from Activity 3:
@Override
public void onBackPressed() {
// start Activity 2
return;
}
See this article for more details.
Note: this only works with Android 2.0 or later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With