Kill all activities when HOME key is pressed android

后端 未结 2 547
一生所求
一生所求 2020-12-09 05:44

I have an app which has 4 activities in it.Within app, history activities, i.e. Activities from where I navigated should not be destroyed , so I don\'t call finish() when I

相关标签:
2条回答
  • 2020-12-09 05:50

    On main activity add:

    android:launchMode="singleTask" android:clearTaskOnLaunch="true"

    On the others add:

    android:finishOnTaskLaunch="true"
    

    This way it will kill off any activity when returning to the app after being in background.

    0 讨论(0)
  • 2020-12-09 06:13

    Set android:clearTaskOnlaunch="true" on the activity launched from the home screen.

    You might also check some of the other attributes you can specify on activity, to tweak it's behavior a bit more.

    0 讨论(0)
提交回复
热议问题