したがって、基本的に、私のサービスは、ユーザーが望む場合にオフにできる通知を表示します。
設定はアプリケーション内から制御され、PreferenceActivity を通じて設定されます。
アクティビティを終了するとき:
public void onDestroy(){
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
debug.postLog(Log.DEBUG, "Settings", "("+this.toString()+") showNotification: " + prefs.getBoolean("showNotification", true));
正しい値を表示します。ユーザーがチェックボックスをオフにすると、false が表示され、その逆も同様です。
一方、サービスでいつでもこれを呼び出すと、次のようになります。
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)){
アプリが完全に停止してから再起動するまで同じ結果が得られ、現在の値が保持されます。サービスが設定のスナップショットを取得するようなものです。
私は何が欠けていますか?