I have 4 activities: A, B, C and D. And one more: E.
Thre is no problem when y start a new activity between A, B, C and D. But in some points of these (for example, when a login is successful) we want to start activity E but clear all A, B, C and D activities (that is, clearing the back stack).
So, I want when yoy arrive to activity E, and press the back button, you will leave of the application.
I am trying do it adding flags in the startActivity: Intent.FLAG_ACTIVITY_CLEAR_TASK, Intent.FLAG_ACTIVITY_CLEAR_TOP and some more, but I can't achieve the behaviour.
Any idea?
Thanks!
Intent intent = new Intent(this, EActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
this.finish();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With