jgibbs wrote:I've just been trying to solve the same problem with a wallpaper I'm putting together. The solution in my case is as follows:
Add a global variable to the wallpaper servlceUsing java Syntax Highlighting
public class LiveWallpaperService extends BaseLiveWallpaperService implements SharedPreferences.OnSharedPreferenceChangeListener { private boolean mSettingsChanged = false; ... } Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Make a function that builds the scene from scratchUsing java Syntax Highlighting
public void BuildScene(Scene scene) { // Destroy the current scene scene.detachChildren(); // Create the scene with currentsettings ... } Parsed in 0.030 seconds, using GeSHi 1.0.8.4
Catch preference changes and set global flag to indicate new settings need to come into playUsing java Syntax Highlighting
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { nMySetting = Integer.parseInt(prefs.getString("num_setting", "3")); mSettingsChanged = true; } Parsed in 0.033 seconds, using GeSHi 1.0.8.4
Call BuildScene from load and resume functions as applicableUsing java Syntax Highlighting
@Override public Scene onLoadScene() { final Scene scene = new Scene(); BuildScene(scene); return scene; } @Override public void onResume() { super.onResume(); if( mSettingsChanged ) { BuildScene( this.getEngine().getScene() ); mSettingsChanged = false; } } Parsed in 0.035 seconds, using GeSHi 1.0.8.4
Thank you so much jgibbs this has helped tremendously
