Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intent.FLAG_ACTIVITY_CLEAR_TOP not working

My Application Flow:

Login->Profile->UpdateProfile->ChangePass

All of my activitys extends FragmentActivity

When I press button in ChangePass Activity I call this code:

Intent intent=new Intent(getApplicationContext(),LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

So It should start LoginActivity and when I press back from LoginActivity then Application should close...But When I press back button from Login Activity the flow is:

ChangePass->UpdateProfile->Profile->Login

Why My back stack is not cleared ?

Note:

I have applied all these solutions but not working: 1.link 2.link

like image 739
Vibhor Bhardwaj Avatar asked Apr 14 '14 13:04

Vibhor Bhardwaj


1 Answers

Very late reply though.
But might help others as it worked for me.

Developers sometimes confuse FLAG_ACTIVITY_CLEAR_TASK with FLAG_ACTIVITY_CLEAR_TOP

Use this instead
intentRestart.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);

like image 125
Salmaan Avatar answered Oct 13 '22 22:10

Salmaan