I have four activies and I have two buttons to navigate between those activities which are named as previous and next.
Now I have gone through many SO answers which were answered previously and got the below code to exit the app when pressed the back button
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
finish();
}
Now my problem is when I navigate to 2nd activity from there to 3rd and finally to 4th activity suppose if users wants to navigate to previous activity he can click the previous button and similarly back button.But if I navigate to the flow shown below:
2----->3---->4
4----->3---->4
or similar combinations and finally when I reached the last activity and user completes his task and decided to exit the app and when clicks the backbutton it simply goes to the previous activities I have gone before
that is as shown above from 4---->3 and 3--->4
Is this is something how the backbutton behaves or can anyone say me what is the right of closing the app when clicked the backbutton.