how to finish all activities and close the application in android?

前端 未结 9 1138
自闭症患者
自闭症患者 2021-01-03 19:53

My application has the following flow:

Home->screen 1->screen 2->screen 3->screen 4->screen 5>Home->screen 2->Home->Screen 3

My problem is that when I am try

9条回答
  •  情话喂你
    2021-01-03 20:15

    To clear all the activities while opening new one then do the following:

    Intent intent = new Intent(getApplicationContext(), YourActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    

提交回复
热议问题