I have a settings activity shown below, this works fine and the logs show
the values changing.
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.util.Log;
public class Settings extends PreferenceActivity implements
OnSharedPreferenceChangeListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences
sharedPreferences,String key)
{
Log.w("SignalSpot","Changed: "+key);
}
}
Then in my broadcast receiver i use sharedPreferences =
context.getSharedPreferences("SignalSpot", 0);
and then sharedPreferences.getBoolean("disconNotification", false); which
always returns the default.
I think i need to call addPreferencesFromResource(R.xml.settings); but i
cannot do that from within the BroadcastReceiver. What am i missing?
Thanks for your assistance.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en