Reputation: 923
So basically, my service displays a notification which can be turned off if the user wishes.
The setting is controlled from within the application and is set through a PreferenceActivity.
When exiting the activity:
public void onDestroy(){
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
debug.postLog(Log.DEBUG, "Settings", "("+this.toString()+") showNotification: " + prefs.getBoolean("showNotification", true));
Shows the correct value, if the user unchecks the checkbox, it shows false and vice versa.
Meanwhile, when I call this at any time in my service:
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
Boolean show = prefs.getBoolean("showNotification", true);
debug.postLog(Log.DEBUG, "Passive Service", "("+this.toString()+") showNotification: " + prefs.getBoolean("showNotification", true));
if(prefs.getBoolean("showNotification", true)){
I get the same result until the app is fully stopped then restarted, then the current value is kept. It is almost like the service gets a snapshot of the preferences.
What am I missing?
Upvotes: 1
Views: 1224