exit entire app at once

前端 未结 2 805
一整个雨季
一整个雨季 2021-01-03 07:37

I have used the code from here in my app, when I click on \'Cancel\' option ,the app just minimizes ,when I long press and hold Home button and select the app.It shows the s

相关标签:
2条回答
  • 2021-01-03 07:48

    u can kill all thread asynctask every running activity with :

    System.exit(0);
    
    0 讨论(0)
  • 2021-01-03 07:53

    Not recommened but still you can use this. Better go with this solution in case you need to quit the app.

    According to me the best solution is finish every activity in your app like below.

    step1) maintain a static variable in mainactivity say.

      public static boolean isQuit = false;
    

    step2) on click event of an button make this variable to true.

       mainactivity.isQuit = true;
       finish();
    

    step3) And in every activity of your application have onrestart method as below..

      @Override
          protected void onRestart() {
             // TODO Auto-generated method stub
             super.onRestart();
            if(mainactivity.isQuit)
                finish();
        }
    
    0 讨论(0)
提交回复
热议问题