Reputation: 13254
I have a MainActivity, then I call SecondActivity (where I choose a file whose data is given to ThirdActivity.
If back button is pushed, I want the app to go back yo MainActivity and not SecondActivity.
How can I do that?
Upvotes: 0
Views: 859
Reputation: 3839
You could also override onKeyPressed()
(or whatever it's called) for the back button and startActivity().
Upvotes: 0
Reputation: 36035
There are two ways to do it.
In SecondActivity, call finish() immediately after you start Activity 3.
Pass in the NO_HISTORY flag in the Intent for SecondActivity when starting it in MainActivity.
Upvotes: 3
Reputation: 58361
Just after you call startActivity with the Intent for activity 3, call finish in activity 2:
//in activity 2
Intent intent = new Intent(...);
startActivity(intent);
finish();
Upvotes: 1