How to close the annex on return from subsidiary activity



  • There are two actives in the annex - auth and dialogs. I'm trying to stop the laser from returning from dialogs to auth. The first thing that comes to mind is the way out of the application to press the back button. Use this code:

     public void onDestroy() {
        moveTaskToBack(true);
        super.onDestroy();
        System.runFinalizersOnExit(true);
        System.exit(0);
    }
    

    There are two problems:

    (1) When compressing back, the previous activity appears for a moment, and only then the annex closes.

    (2) In forums, it was stated that the use of System.exit(0) was not recommended, but no alternatives were found.

    Help me figure this out.



  • When you move in, use the flags to clean the leak.

    Intent main = new Intent(AlarmActivity.this, MainActivity.class);
        main.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(main);
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2