-3

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?

Yatin
  • 2,969
  • 9
  • 34
  • 68
harsh
  • 1

3 Answers3

0

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.

Charu
  • 1,055
  • 13
  • 18
0

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);
zMabrook
  • 932
  • 7
  • 9
-1

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();
}