How to control Activity flow - Back button versus Home button

后端 未结 4 1456
眼角桃花
眼角桃花 2021-01-01 05:52

I have 3 activities in my application:

Activity1 -> Activity2 -> Activity3

Inside Activity3, if the user presses Back, I would like t

4条回答
  •  梦毁少年i
    2021-01-01 06:35

    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.

提交回复
热议问题