I am using a toggle button in my applications settings page. The problem is, that once I turn the toggle button on and exit from the settings page and then again go to settings, it shows that toggle button is in off state. I want it in the on state until the user turns it off, even if the app is closed… Is it possible?
I am using a toggle button in my applications settings page. The problem is,
Share
You should use SharedPreferences for that with an
onCheckedChangedListener.Here’s an example how I’m handling it for a CheckBox (should be equal to a ToggleButton, so it’s untested, but should work!):