Activity launcher
I have three activities like Activity A - Activity B - Activity C . Activity launch through intent. When Activity C is launched and I click back button to get activity A with out handle back pressed. How can I get this?
Activity launcher
I have three activities like Activity A - Activity B - Activity C . Activity launch through intent. When Activity C is launched and I click back button to get activity A with out handle back pressed. How can I get this?
When you are launching Activity C from B then after startActivity()
method call finish() in Activity-B. It will remove Activity-B from activity-stack.
If you are in Activity C and you want to go back to Activity A without going to Activity B you should use flags.
Intent startActivityA = new Intent(ActivityC.this,ActivityA.class);
startActivityA.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startActivityA);
while calling activity C from activity B, you can call finish() method after calling intent. see the syntax below.
@Override
public void onBackPressed() {
super.onBackPressed();
Intent intent=new Intent(B.this,C.Class);
startActivity(intent);
finish();
}