How to limit the number of the same Activity on the stack for an Android application

后端 未结 2 1149
攒了一身酷
攒了一身酷 2021-01-06 16:34

Is this possible in an Android app? I want to make it so that no matter how many times a user starts activityA, when they hit the back button they will never get more than o

2条回答
  •  無奈伤痛
    2021-01-06 17:25

    You might want to set your activity as singleTop -- this basically means that you can have multiple instances, but the app will reuse an instance if you try to launch an instance on top of itself. See the Android documentation on Activities and Tasks.

提交回复
热议问题