I have 3 activities. Activity A which leads to activity B, which in turn can go back to activity A or start activity C. However, if I press back in activity C the app should
I didn't do any of this. This is how I would revise your code.
the code you use to enter another intent:
Intent whatEverIntentName = new Intent("Path.to.next.Intent");
startActivity(whatEverIntentName);
finish();
This way, you always quit when pressing back. But wait! You can change how you want your back key press to react when pressed.
Do this:
@Override
public void onBackPressed() {
super.onBackPressed();
Intent whatEverIntentName = new Intent("Path.to.the.activity.before.it");
startActivity(whatEverIntentName);
// Don't add finish here.
//This is necessary because you finished your last activity with finish();
}