How to prevent going back to the previous activity?

前端 未结 13 1044
眼角桃花
眼角桃花 2020-11-27 09:10

When the BACK button is pressed on the phone, I want to prevent a specific activity from returning to its previous one.

Specifically, I have login and sign up screen

13条回答
  •  醉话见心
    2020-11-27 09:58

    My suggestion would be to finish the activity that you don't want the users to go back to. For instance, in your sign in activity, right after you call startActivity, call finish(). When the users hit the back button, they will not be able to go to the sign in activity because it has been killed off the stack.

提交回复
热议问题