I am trying to create a livewallpaper for android which uses Android 8.1's WallpaperColors API to change systemUI to dark or light depending on the livewallpaper color. This is my LiveWallpaperAndroid.java
public class LiveWallpaperAndroid extends AndroidLiveWallpaperService {
String TAG="LiveWallpaperAndroid";
@Override
public void onCreateApplication () {
super.onCreateApplication();
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.numSamples=0;
config.useCompass = false;
config.useWakelock = false;
config.useAccelerometer = false;
config.getTouchEventsForLiveWallpaper = true;
ApplicationListener listener = new LiveWallpaperStarter();
initialize(listener, config);
if (Build.VERSION.SDK_INT >= 27) {
linkedEngine.notifyColorsChanged();
Log.d(TAG,"trying to notify from onCreate()");
}
}
public class MyLiveWallpaperListener extends LiveWallpaperScreen implements AndroidWallpaperListener {
public MyLiveWallpaperListener(Game game) {
super(game);
}
@Override
public void offsetChange (float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) {
}
@Override
public void previewStateChange (boolean isPreview) {
Log.i("LiveWallpaper test", "previewStateChange(isPreview:"+isPreview+")");
}
}
When I call notifyColorsChanged() from on create , this is what shows up in the logcat
W/WallpaperService: Can't notify system because wallpaper connection was not established.