The application is a simple LiveWallpapers written using LibGdx. The offsetChange
method offsetChange
responsible for offsetting the background of live wallpaper, and the variable xPixelOffset
takes a value from 0 to 1. For example, if the device has 3 desktops, when scrolling through the wallpaper, the variable xPixelOffset
takes the value 0, 0.5, 1 on each desktop, respectively. The problem is that this algorithm does not work on all devices. At Sony Xperia M (API 18) works without complaints. On Samsung Galaxy Tab 2 (API 17) and HTC Desire 601 (API 17), the above mentioned algorithm does not work and the desktop background remains motionless when scrolling through wallpapers. Code attached: AndroidLauncher.java
public class AndroidLauncher extends AndroidLiveWallpaperService { public static float pixeloffset = 0; @Override public void onCreateApplication () { super.onCreateApplication(); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); config.useCompass = false; config.useWakelock = false; config.useAccelerometer = false; config.getTouchEventsForLiveWallpaper = true; final ApplicationListener listener = new MyLiveWallpaperListener(); initialize(listener, config); } public class MyLiveWallpaperListener extends MyWallpaper implements AndroidWallpaperListener{ @Override public void create() { super.resolver = new Resolver() { @Override public float getxPixelOffset() { return pixeloffset; } }; super.create(); }; @Override public void offsetChange(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) { pixeloffset = xPixelOffset; } @Override public void previewStateChange(boolean isPreview) { } } }
I ask for help in explaining the reasons for such a strange work of this method, as well as the ways of its possible replacement.