I use AActivity call BActivity, and BActivity call CActivity.
As below code:
In AActivity:
Intent intent = new Intent();
intent.setClass(AActivity.this, BActivity.class);
startActivity(intent);
In BActivity:
Intent intent = new Intent();
intent.setClass(BActivity.this, CActivity.class);
startActivity(intent);
If in CActivity I pressed back button, I want to launch AActiviy directly.
But not call BActivity.
How can I modify it?
In BActivity:
This will pop B off the back stack, so that when you press the back button from CActivity, the next one in the stack, AActivity will be displayed.
Note – This differs from the answer above. In this approach, you return to AActivity in its previous state (for the most part). In the first answer above, you would be launching a new instance of AActivity thus adding one more activity to the back stack. You need to pick which approach suites your needs better.