I have made a live wallpaper, which has many complex settings. Looking at various examples on the web it appears that the standard way to set preferences in a wallpaper is to have some xml like this:
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:thumbnail="@drawable/my_icon"
android:description="@string/wallpaper_description"
android:settingsActivity="com.mycompany.mywallpaper.MyWallpaperSettings"
/>
Where MyWallpaperSettings
is a class defined like this:
public class MyWallpaperSettings extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener
with...
@Override
protected void onCreate(Bundle blah)
{
super.onCreate(blah);
getPreferenceManager().setSharedPreferencesName(MyWallPaper.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.my_settings);
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
This all works as advertised, but it appears rather crude. I have noticed that the look and feel of some wallpaper's settings is far more sophisticated, or look nothing like the standard settings screens at all, some have a dialog that pops up, with buttons on that are links to websites. I am wondering how I can achieve this. Is it all about having fancier xml in my_settings.xml or perhaps the android:settingsActivity=.. points to something that isn't a PreferenceActivity, but rather just a normal activity? Or maybe the code within the oncreate needs to look different - I'm just not sure exactly where I should be deviating from the examples.
Looking at developer.android.com it says "This is the base class for an activity to show a hierarchy of preferences to the user." - this sounds like I'm restricted to a narrow range of things I can do... that's why I'm torn between attempting to push the limits of what can be done inside a PreferenceActivity and making android:settingsActivity=
point to something that simply isn't a PreferenceActivity at all (if that's allowed).
According to this you don't need to have a PreferenceActivity, any Activity will do.
PreferenceActivity is an easy way to have a settings screen, but if you don't want to use you can create your own.