Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a settings activity for Android Live Wallpaper

How to create a settings activity in live wallpaper like this?

Example Picture

I've built settings activity with only a simple text and faced some problems. The first problem is that I can't use layout XML file for this activity. The second: I can't set the directory to system icon (drawable/ic_menu_more) when I try to build that activity programmly. Also I will need do use SeekBar.

I will be very pleased, if you help me =)

like image 723
Finesse Avatar asked Dec 28 '11 05:12

Finesse


People also ask

How to program a live wallpaper Android?

To set a live wallpaper, tap on the 'Set as launcher wallpaper' button, check the preview, and tap on 'Set wallpaper. ' The app lets you set videos as live wallpapers on just the homescreen or the homescreen and lockscreen both.

What is the file of a live wallpaper on Android?

The users can either use GIF files or Video files to set the Live Wallpaper on Android devices.

What is the file format of live wallpaper?

If you want to be able to use a video as a live wallpaper on Android devices, you have to make sure that the video is an . mp4 format.


2 Answers

For using system icon:

<service android:name="com.livewallpaper.warm.LiveWallpaper"
            android:label="@string/app_name"
            android:icon="@drawable/ic_menu_more">

            <intent-filter>
                <action android:name="android.service.wallpaper.WallpaperService" />
            </intent-filter>
            <meta-data android:name="android.service.wallpaper"
                android:resource="@xml/livewallpaper" />

        </service>

In XML-livewallpaper.xml:

<?xml version="1.0" encoding="utf-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
    android:settingsActivity="com.livewallpaper.warm.LiveWallpaperSettings"
    android:thumbnail="@drawable/ic_menu_more"/>
like image 186
Mohit Verma Avatar answered Nov 08 '22 06:11

Mohit Verma


The LiveWallpaper Example on the Android Dev site (now cached) goes through exactly that: http://web.archive.org/web/20111229075658/http://developer.android.com/resources/samples/CubeLiveWallpaper/index.html

More specifically: http://web.archive.org/web/20120104043512/http://developer.android.com/resources/samples/CubeLiveWallpaper/src/com/example/android/livecubes/cube2/CubeWallpaper2Settings.html

In short:

public class CubeWallpaper2Settings extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener {

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    getPreferenceManager().setSharedPreferencesName(
            CubeWallpaper2.SHARED_PREFS_NAME);
    addPreferencesFromResource(R.xml.cube2_settings);
    getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(
            this);
}

@Override
protected void onResume() {
    super.onResume();
}

@Override
protected void onDestroy() {
    getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(
            this);
    super.onDestroy();
}

public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
        String key) {
}
}
like image 30
TryTryAgain Avatar answered Nov 08 '22 06:11

TryTryAgain