Reputation: 780
In my application after the user goes from one activity to another and vice versa. Im calling the activities using Intents on the event "onClick".
public void onClick(DialogInterface dialog, int whichButton) {
Intent intent = new Intent();
intent.setClass(Field.this,Boll.class);
startActivity(intent);
finish();
}
After using the application when the back button is pressed then application must end and should go back to the Home screen.
However what happening in my app is, when the Back button is clicked the activities are still in the stack and are traced back one by one(i.e to their previous state), and finally returns back to the Home Screen.
I have learned that Android takes care of quitting the application, from here
Please let me know where should i add the finish()
in order to finsh all activities in the stack and go back to Home Screen(i.e to end the application).
Upvotes: 1
Views: 6783
Reputation: 48615
You should try adding the noHistory
attribute to your activities
http://developer.android.com/guide/topics/manifest/activity-element.html#nohist
You shouldn't manually handle the stack. There is no way to "finish" all the activities in an application. Android is designed to pick the application up where it left off. Making the "back" button close out of the app instead of closing the current activity could be very confusing and frustrating to your users.
Upvotes: 7