0

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).

Mick
  • 8,284
  • 22
  • 81
  • 173
  • it is really hard to say what was asked here: theme http://stackoverflow.com/questions/11751498/how-to-change-preferenceactivity-theme ? custom layout http://stackoverflow.com/questions/2697233/how-to-add-a-button-to-preferencescreen ? – Selvin Apr 18 '13 at 12:16
  • The links you put in your comment are already useful - so it can't be that hard. But I will make some edits to my post. – Mick Apr 18 '13 at 12:21

1 Answers1

1

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.

Marcio Covre
  • 4,556
  • 2
  • 22
  • 24
  • presumably I should still add "implements SharedPreferences.OnSharedPreferenceChangeListener" so the wallpaper will get to know about the changes. – Mick Apr 18 '13 at 12:44
  • Yes, if you're not using the PreferenceActivity, you must save the settings yourself to SharedPreferences and the Wallpaper have to use OnSharedPreferenceChangeListener to be notified of changes – Marcio Covre Apr 18 '13 at 12:52