I’d like to set my newly created activity to be the only one on the stack and be on top of it as well, so when Activity B is created from A, I can press back to return to home menu from B.
Accordingly, this is what I did
public void onClick(View v) {
Intent i = new Intent(this,B.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i);
}
For some reason, after Activity B starts, pressing back still takes me to A.
What am I missing here?
do like this
call finish() after startactivity(…), so that
A activity ll removed from the stack. when you press back button A activity ll be not there in stack.