Muhammad Yaseen :
I want to move to another activity but before i want to clear all the other activity. I know the method Intent.FLAG_ACTIVITY_CLEAR_TOP but it does not work when i back pressed after moving then it again show the previous one activity. My code is
Intent intent = new Intent(LoginActivity.this, WelcomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
progressDialog.dismiss();
Thanks Advance
Zeeshan Majeed :
Sometimes it doesn't work you should add this line in your code
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK);
It will help you and hopefully your issue will resolve. I've added this line in your code and after adding that line your code will look like this
Intent intent = new Intent(LoginActivity.this, WelcomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_CLEAR_TASK |
Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
progressDialog.dismiss();
Replace your code with the above code.