Android Live Wallpaper – Tutorial

Android Live Wallpaper. This tutorial describes the creation of live wallpapers for Android. It is based on Eclipse 4.2, Java 1.6 and Android 4.1 (Ice Cream Sandwich).


Android Live Wallpaper. This tutorial describes the creation of live wallpapers for Android. It is based on Eclipse 4.2, Java 1.6 and Android 4.1 (Ice Cream Sandwich).


1. Pre-requisitions

The following tutorial assumes that you have already basic knowledge in Android development. Please check the – Android development tutorial to learn the basics.

2. Overview

2.1. Live Wallpapers

Live Wallpapers are animated, interactive backgrounds for the Android home screen. A live wallpaper is similar to other Android applications and can use most of the same functionality.

2.2. How to create a live wallpaper

To create a live wallpaper, you need to create an XML file which describes your wallpaper. This file should contain a description of the application and can contain a preview and a link to a preference activity Activity which allow to customize the live wallpaper.

You also create a service which must extend the WallpaperService class. This class is the base class for all live wallpapers in the system. You must implement the onCreateEngine() method and return an object of type android.service.wallpaper.WallpaperService.Engine. This objects handles the lifecycle events, animations and drawings of the wallpaper. The Engine class defines the life cycle methods, as for example onCreate(), onSurfaceCreated(), onVisibilityChanged(), onOffsetsChanged(), onTouchEvent() and onCommand().

The service requires the permission android.permission.BIND_WALLPAPER and must be registered via an intent-filter for the android.service.wallpaper.WallpaperService action.

You should also enter in the AndroidManifest.xml file of the application that your application uses the feature. This will prevent that your wallpaper can be installed on devices which do not support live wallpapers.

2.3. Intent to set the wallpaper

You can use an Intent to set the Wallpaper.

// Button to set the Wallpaper
public void onClick(View view) {
        Intent intent = new Intent(
                new ComponentName(this, MyWallpaperService.class));

3. Android Wallpaper Example

Create a new project called Do not create an activity.

Create the /res/xml folder and create the mywallpaper.xml file.

<?xml version="1.0" encoding="UTF-8"?>

This file contains a description of your wallpaper and a preview graphic. You can also enter a link to an activity which allow to configure the wallpaper. This resource file will be linked to from the AndroidManifest.xml. You could also include the “android:thumbnail attribute” which would point to a drawable which gives a smaller image of the running wallpaper.

Change your AndroidManifest.xml to the following to define your MyWallpaperService service. Also define the uses-feature.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    android:versionName="1.0" >

        android:label="@string/app_name" >
            android:label="Wallpaper Example "
            android:permission="android.permission.BIND_WALLPAPER" >
                <action android:name="android.service.wallpaper.WallpaperService" >

                android:resource="@xml/mywallpaper" >

            android:theme="@android:style/Theme.Light.WallpaperSettings" >
            android:theme="@android:style/Theme.Light.WallpaperSettings" >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

    <uses-sdk android:minSdkVersion="10" />

        android:required="true" >


We create the MyPoint class to save the elements we have drawn.


public class MyPoint {
        String text;
        private int x;
        private int y;

        public MyPoint(String text, int x, int y) {
                this.text = text;
                this.x = x;
                this.y = y;

You may also like


Android Widgets – Tutorial

The following description assume that you already have experience in building standard Android application. Please see – Android Tutorial. It also partly uses Android services. You find an introduction into Android Services in – Android Service Tutorial.