0

I have this stack:

Login Activity -> Registration Activity

After a successful registration I call this:

Intent i = new Intent(getApplicationContext(),Home.class);
i.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK );
startActivity(i);
finish();

And this finish my Registration activity BUT not my Login activity, so my stack stay like this:

Login Activity -> Home Activity

Any advice?

Nicolas Durán
  • 292
  • 8
  • 19

3 Answers3

1

use this with intent in order to clear the backtrace activities

Java

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

Kotlin

 var intent = Intent(this, [Your_activity]:class.java)
        intent.flags =  Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
        startActivity(intent)
Abhay Pratap
  • 1,886
  • 11
  • 15
0

To clear activities on the top of the stack ,

Intent i = new Intent(getApplicationContext(), Home.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.putExtra("EXIT", true);
startActivity(i);
finish();
BDRSuite
  • 1,594
  • 1
  • 10
  • 15
0

Well, i ended up using this answer

Clear the entire history stack and start a new activity on Android

And that do exactly what Im trying to do

Community
  • 1
  • 1
Nicolas Durán
  • 292
  • 8
  • 19