O'Reilly logo

Android 3.0 Animations by Alex Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—updating live wallpaper configuration

We want to add an event listener to the live wallpaper so that it is notified as soon as its configuration is changed. When it is changed, we are going to read the SharedPreferences object that has been updated.

  1. Open up BubblesWallpaperService.java and navigate to the BubbleWallpaperEngine class. We will add an interface from SharedPreferences:
    private class BubbleWallpaperEngine extends Engine
    implements SharedPreferences.OnSharedPreferenceChangeListener
    
    {
    
    • This allows us to listen for changes in the shared preferences, but first we must provide an implementation of the interface.
  2. Add the following method to BubbleWallpaperEngine to complete the implementation:
    public void onSharedPreferenceChanged( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required