I am trying to write a settings activity in an application on Eclipse. In the Main Activity, it has a button that runs a certain command. In the settings activity, I want to have a checkbox that when checked, changes what the button in the Main Activity runs when it is tapped. Right now, I have it so that when the checkbox is checked, it changes the value of a boolean and passes it to the main activity. When the button in the main activity is tapped, it checks to see if the boolean is true or false. All of this works perfectly, but when I return to the settings activity after that, the checkbox is unchecked. What should I do to have it stay checked after I go to another activity?
|
I believe the comment I posted is the answer: You need to save the state of the activity. This information can be found at Saving Activity state in Android but in short you need to override these two methods:
and
|
|||||||||||||
|
you can use shared preference in android to store state. take look at this http://developer.android.com/guide/topics/data/data-storage.html#pref and http://www.androidhive.info/2012/08/android-session-management-using-shared-preferences/ |
|||||||||
|