Skip going back to direct parent activity when pressed back

Very simple!! When you are starting the activity C, from B, use B.finish(). Something like this.

Intent i = new Intent(B.this, C.class);
B.this.finish();
startActivity(i);

This will remove B from the stack!


Probably late, but for people who might find this in a search: You can add

        android:noHistory="true"

to your activity B in your AndroidManifest. This will also avoid that the onActivityResult() method is called in activity B when C returns a result though. I'ts basically like B disappears as soon as you start C.


Set a flag for B activity like this

private boolean mDestroyActivity = false;

set that flag true when you call startActivity C.

for activity B onStop method add checking like this:

if (mDestroyActivity) finish();

Then when you press back button in C you will jump back to A.