So I have this big stupid problem with the preferences in my live-wallpaper.
First, PreferenceManager.getDefaultSharedPreferences
, doesn't work. I'm calling it in my Main class, a subclass of WallpaperService in the function onCreate. For the parameter, I first tried "this" and then this.getBaseContext()
, but it doesn't matter. So, when I print the values, nothing shows up!
Second, I saw in another answer here that to put some default values, use something like PreferenceManager.setDefaultValues(this.getBaseContext(), R.xml.setting, true);
. So, this, doesn't get my defaultValues at all. They're all zeros and even one values from my setting.xml
doesn't show up in the list. I explicitly put a android:defaultValue
for each of them.
Note that once I put values for each of them in the preferences, this problem doesn't happen. But still, for someone who installs my app, it needs to work on the first time it's launched.