Suppose there are two Activities :
1. Activity A (Launcher Activity)
2. Activity B
When Launching Activity B from Activity A, I finish the Activity A.
startActivity(new Intent(A.this, B.class));
finish();
and If exit button clicked from Activity B, the Activity B get finished.
ExitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
So, suppose Activity B get launched from Activity A, and I get exit from Activity B (or exit from Application). There are 2 option, from where the application get launched :
1. From launcher icon
2. From Recent Apps
Now, If the application launched from launcher icon , then Activity A get launched. But If the application launched from Recent Apps, then Activity B get launched.
I think, Activity B remains in stack, even if the I call finish() for it.
My Question is : How can I clear the stack, when application get exit ? Tested in Android 2.3.6 version