androidopengl-esandroid-2.1-eclair

How to avoid pausing android live wallpaper while settings activity is open when using GLSurfaceView


I am writing a 3d live wallpaper for android using the famous GLSurfaceView wrapper (http://www.rbgrn.net/content/354-glsurfaceview-adapted-3d-live-wallpapers)

When i open the preference screen to change wallpaper settings, the settings are displayed as transparent over my wallpaper preview. This is good because it lets me preview the settings changes I make. This works great, except for one problem: The live wallpaper is paused as long as the settings are on top of it!

How can i avoid my wallpaper pausing?


Solution

  • I came up with a workaround which could be useful, depending on how your wallpaper functions...

    In my settings activity, whenever the user makes a change (e.g. moves a slider, checks a checkbox), I broadcast an Intent with the relevant settings information.

    In the live wallpaper's onCreate method, I dynamically register a BroadcastReceiver to receive these settings events. I unregister this receiver in onDestroy.

    When receiving a settings broadcast, I make the wallpaper draw a single frame with the new settings. As the settings activity is transparent, this immediately gives the user an idea of what the wallpaper will look like with the chosen settings.

    Similarly, using this approach, you could schedule the wallpaper to animate for a few seconds after a settings change — or whatever is appropriate for your implementation.