Basically you want to switch the order of the current background and previous background. To do this, you can start the previous operation and use the flag FLAG_ACTIVITY_REORDER_TO_FRONT:
Intent intent = new Intent(this, MyPreviousActivity.class); intent.setFlags(FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent);
So, if you have tasks A, B, C and task C calls startActivity () with activity B, then B will be moved to the beginning of the action stack with the resulting order A, C, B, which is what you requested.
See Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
source share