简体   繁体   中英

Reset Activity when phones back button is clicked

Is it possible to reset a activity to its normal state when a user clicks the back button from the previous page.

Use Case: On my main activity I have checkboxes and the user goes to the next activity using intent. That activity has a "Back to Main Page" button, but when the user just clicks the back button on the phone the checkboxes are already checked from the last time the user was on the page.

If you want to reset only when returning from that activity then use startActivityForResult() and override onActivityResult .

If you want to reset everytime then reset in onResume()

将设置复选框默认状态的代码从onCreate()移到onResume()方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM