Android Live wallpaper Tutorial

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.


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 [su_highlight background=”#F7F7F7" color=”#EA1F00"]WallpaperService [/su[/su_highlight]ss. This class is the base class for all live wallpapers in the system. You must implement the [su_[su_highlight background=”#F7F7F7" color=”#EA1F00"]eateEngine()[/su_hig[/su_highlight] and return an object of type [su_high[su_highlight background=”#F7F7F7" color=”#EA1F00"]service.wallpaper.WallpaperService.Engine[/su_highlig[/su_highlight]ts 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 [su_highligh[su_highlight background=”#F7F7F7" color=”#EA1F00"]ission.BIND_WALLPAPER[/su_highlight][/su_highlight]gistered via an intent-filter for the [su_highlight ba[su_highlight background=”#F7F7F7" color=”#EA1F00"]wallpaper.WallpaperService[/su_highlight] act[/su_highlight] should also enter in the [su_highlight backgr[su_highlight background=”#F7F7F7" color=”#EA1F00"]/su_highlight] file of[/su_highlight]n that your application uses the [su_highlight background[su_highlight background=”#F7F7F7" color=”#EA1F00"]llpaper[/su_highlight] feature. Th[/su_highlight] that your wallpaper can be installed on devices which do not support live wallpapers.

 In this tutorial we will be creating a cube  which will rotate in 3D space. This can be set as live wallpaper from live wallpaper chooser.

 

[su_button url=”https://gi[su_button url=”https://github.com/androidsrc/SimpleLiveWallpaper” target=”blank” style=”stroked” background=”#51d461" color=”#ffffff” size=”6" center=”yes” radius=”0" icon=”icon: arrow-circle-o-down”]u_button]

 

[su_[/su_button]”http://youtu.be[su_youtube url=”http://youtu.be/9eQf4EmKn9g”]p>1. Create a new project in Eclipse by navigating to File ⇒ New Android ⇒ Application Project and fill required details.

2. Now create file in res/xml/cube.xml. This will provide settings to android live wallpaper manager. For now we are not entering anything. It is just declaring a live wallpaper.

[Format Time: 0.0047 seconds]we have to update AndroidManifest.xml so that it can include cube.xml file. We also have to declare the service which will provide animated cube to display as wallpaper. Update file looks like this.

[Format Time: 0.0011 seconds]ackground=”#F7F7F[su_highlight background=”#F7F7F7" color=”#EA1F00"]in your default packa[/su_highlight]do all the animation and construction of the cube.It extends [su_highlight background=”#F7F7F7″[su_highlight background=”#F7F7F7" color=”#EA1F00"] is responsible for[/su_highlight] wallpaper behind applications that would like to sit on top of it. CubeWallpaper host another class [su_highlight background=”#F7F7F7″ col[su_highlight background=”#F7F7F7" color=”#EA1F00"]he [su_highlig[/su_highlight]#F7F7F7″ color=[su_highlight background=”#F7F7F7" color=”#EA1F00"]the dirty [/su_highlight]ne super class provide all the callback methods which are used to handle the wallpaper drawing and interaction. Code of CubeWallpaper.java goes like this.

4. <[Format Time: 0.0124 seconds]ject.
5. To set livewallpaper go to Launcher > Menu > Home Screen Wallpaper > Live Wallpaper > Cube Live Wallpaper and press set live wallpaper.

GuRu

Technology enthusiast. Loves to tinker with things. Always trying to create something wonderful using technology. Loves coding for Android, Raspberry pi, Arduino , Opencv and much more.

You may also like...

1 Response

  1. Narendra Kakkad says:

    I tried your example. When I try to run it, it says that there is no default activity.
    Actually I am a newbie in android. And the post is also too old. But if you can reply, then it would be grt.

    Thanks in advance…

Leave a Reply

Your email address will not be published. Required fields are marked *