-2

I do start an activity A using intent from within aPreferenceScreen. What I do want to do is pretty simple. Depending on some actions the user may take I want to finish all previous activities and start the LoginActivity. Something like restarting the whole application.

DeKekem
  • 589
  • 10
  • 20
  • 3
    Possible duplicate of [Finish all previous activities](http://stackoverflow.com/questions/6330260/finish-all-previous-activities) – baldguy Dec 30 '16 at 17:51

3 Answers3

4

Use Intent.FLAG_ACTIVITY_CLEAR_TASK flag in intent to clear all the activities in the stack

Intent i = new Intent(CurrentActivity.this, NewActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
startActivity(i);
Siva
  • 457
  • 4
  • 17
0

Just use finishAffinity() after startActivity().

kjdion84
  • 9,552
  • 8
  • 60
  • 87
0

Just use finishAffinity() after startActivity()

eweb Team
  • 1
  • 1