Android: Clear Activity History
Solution 1:
I didn't understand your question 100%
I think you are facing problem with activity stack and CLEAR_TOP
so use startActivityForResult instead of startActivity
Solution 2:
The way we fixed it is taking a static boolean variable in the immediate first activity .Say your first activity is A,In A declare variable as below
publicstaticboolean closeAllActivities=false;
Then in rest of all activities place the below code in onResume()
protected void onResume() {
super.onResume();
if(A.closeAllActivities)
{
finish();
}
else
{
// TODO your requirement inside onResume
}
}
And wherever u would like to exit the application set as
A.closeAllActivities=true;//It exits all the activities one after other.
Solution 3:
It seems I have managed to fix it but it is still a bit strange. I have set launchMode=singleInstance to A and B activities. And call any activities without any flags. No black screen with 1 second delay between activity`s calling. A bit strange solution because google not recommend use singleInstance or singleTask for general situations, I think it's general. If someone will find a better solution you are welcome.
UPDATE: One more very important thing when build and start apk via IDE. Some kind of IDE start app wrongly see this post. Due to it stack behaviour can be changed.
Post a Comment for "Android: Clear Activity History"