In A:
Intent intent = new Intent(B.class, this);
startActivity(intent);
finish(); //finish A behind you so you can only explicitly return to it
In B, two methods for the buttons, I guess, that get you to either C or D:
public void buttonToC(View view){
Intent intent = new Intent(C.class, this);
startActivity(intent);
}
public void buttonToD(View view){
Intent intent = new Intent(D.class, this);
startActivity(intent);
}
In C and D, you can optionally finish the Activity if you press back:
public void onBackPressed(){
Intent intent = new Intent(B.class, this);
startActivity(intent);
finish(); // optional
}
So A -> B and A finishes. From B -> C OR D but B is still running in the background. When in C or D, pressing back brings up the background activity, B. This should work.