Reputation: 923
I would like to be able to remove activities from history but only after a certain threshold has been reached. The structure of my application goes like this:
Home --> User Input --> User Input --> User Input --> Posting in DB
I would like to make it so that while the user is giving data in the input pages, they can easily go back and make a change if necessary, but once they have created a database entry they should not be able to move backwards throughout the forms in previous activities, but instead selecting back should take them straight to "Home".
I am aware of the finish()
as well as android:noHistory="true"
methods but these doesn't really work for delaying the history removal until later. Any Thoughts?
Upvotes: 0
Views: 54
Reputation: 1721
At the below code, it removes all activities from history, and starts home activity.
@Override
public void onBackPressed() {
Intent intent = new Intent(getApplicationContext(), Welcome.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
Upvotes: 1