At the 89th SPIN meeting recently, Ewald Horn of Wysetalk talked about Android Live Wallpaper development. The first part of the talk was around the hows and whys, and the second part was a code demonstration. The slides and the code are available on the SPIN event page. Below are my brief notes from his talk.
Live wallpapers are good for Android version 2.1 and up. They are very popular, and they are fun and easy to develop since Android can handle a lot of the hard work for you. They can be used as brand awareness and marketing tools They're better with the sound off, though, and can be big battery drainers. Live wallpapers offer a good starting path into Android game development. The most popular wallpapers are very similar to games (that mostly play themselves).
Since live wallpapers are a service, there are a number of things that we know. Wallpapers:
- run all the time;
- have access to system resources;
- have access to the Android platform;
- don't require the NDK, so you don't need to go native;
- need to handle a lot of events.
Vogella - Live Wallpaper tutorial is a good starting point, but watch out for some typos and bugs.
It's easy to get started because all you really need are some config files and settings in a manfiest file. The only permission required is android.permission.BIND_WALLPAPER. The building blocks you need are the Live Wallpaper service (which you Extend) and the settings Activity. Use the boilerplates that are provided to make it easier for yourself. The WallpaperService Engine handles rendering, lifecycle and interactions. Rendering uses Canvas. It's possible to use OpenGL if you want or need to, but it's much trickier. The API is very helpful, especially for hi-dpi concerns. For the lifecycle it's important to track visibility and changes. You should be asking: can I draw, should I draw? Think about possible interactions: touch and gestures.