Reputation: 4055
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.
Upvotes: 0
Views: 524
Reputation: 24235
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()
Upvotes: 3
Reputation: 6592
Move the code that sets the default state of the checkboxes from the onCreate()
to onResume()
method.
Upvotes: 1