How to exit when back button is pressed?

前端 未结 12 1269
名媛妹妹
名媛妹妹 2020-11-27 11:47

When a user presses the back button on an intent, the application should quit. How can I ensure the application quits when the back button is pressed?

12条回答
  •  迷失自我
    2020-11-27 12:13

    The app will only exit if there are no activities in the back stack. SO add this line in your manifest android:noHistory="true" to all the activities that you dont want to be back stacked.And then to close the app call the finish() in the OnBackPressed

    
    

提交回复
热议问题