I want to program Home button, so it will remove all Activities
in stack, except one. I did it like in here: How to finish every activity on the stack except the first in Android
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
switch (itemId) {
case android.R.id.home:
Intent intent = new Intent(this, AMainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
break;
...
but this way doesn't suit me, because it removes ALL Activities
(including the first one) and starts the first one again. For example - if I check user password in onCreate()
, he would be asked again.
How to remove all Activities
from stack, but so the first one will not be "touched" ?