0

There are three activities: A, B, C;

A, B are normal activities, C is transparent activity to show a kind of guide.

I programmed when I go B from A, C starts automatically on B.

The problem is when I instantly press back button at when B starts,

C shows up on A.

I want to solve this problem, please help.

  • 6
    This is already answered: http://stackoverflow.com/questions/10379134/finish-an-activity-from-another-activity – NaviRamyle Nov 26 '15 at 03:10

1 Answers1

-1

You could inside activity B

@Override
public void onBackPressed() {
     // Here finish activity C
     super.onBackPressed();
}

Other solution: Keep a public reference to Activity C

  1. In the manifest.xml set Activity C launchMode = "singleInstance"
  2. Inside Activity C:
public static Activity activity;
onCreate(){
    activity = this;
}
  1. Finish it from any activity:
if(ActivityC.activity != null) {
    ActivityC.activity.finish();
}
Daniel Cardenas
  • 2,826
  • 2
  • 19
  • 17