I have three Activities - A B and C, of which B is a Tab Activity. Activity A is launched first, and B is launched from A. I finish Activity A when B is launched using this code
public void onStop() {
super.onStop();
this.finish();
}
Now I want to launch Activity C when back key is pressed in B.
I tried overriding back key using this code
@Override
public void onBackPressed() { this.getParent().onBackPressed();
}
This doesn't Help as the Parent Activity is finished while launching the Child Activity. What actually happens when I press back key is that the Activity exits to the Home screen.
I tried overriding the back key and setting an Intent to it
@Override
public void onBackPressed() {
Intent backIntent = new Intent();
backIntent.setClass(this, main.class);
startActivity(backIntent);
}
This also doesn't help me. What could be a possible solution to this problem, How can I launch Activity C when back key is pressed ?