I have four activities: activity 1, activity 2, activity 3 and activity 4.
When I open the app, I find myself in activity 1, then step into activity 2, then step into activity 3 and finally step into activity 4.
When I'm in activity 4 there's a button that sends me to activity 1, if I press the "Back" button back to activity 4.
I would like that when I step from activity 4 to activity 1, if I press the "back" button while I'm in activity 1 I go out of the loop.
My question is about I do not want to go back, I want to get out of the app when I press "back" in activity 1.
Can you give me some advice on how to do it?
You can override
onBackPressed()
method ofActivity1
and inside this put following code :Also you can try following :