Search code examples
javaandroidlive-wallpaper

Android Live Wallpaper Question


I'v been tinkering with Live Wallpapers today and wouldn't you know it, I just can't get it to work.

I decided to come up with the most simple live wallpaper possible and build from there but even that is going wrong! This is what my WallpaperService class consists of,

    @Override
    public Engine onCreateEngine() {
 return new SimpleEngine();
    }
    public class SimpleEngine extends Engine {

        @Override
        public void onSurfaceCreated(SurfaceHolder holder) {
            super.onSurfaceCreated(holder);

            Canvas c = holder.lockCanvas();
            Paint paint = new Paint();
            paint.setColor(Color.BLUE);
            c.drawCircle(50, 50, 50, paint);
        }
    }

All I wanted to test was if I could make a little circle appear on the screen, but when I go to set it as my wallpaper it just says "Loading live wallpaper..." and doesn't budge (but it doesn't freeze either). The code is getting called but I'm not sure whats going wrong.

Could someone point it out for me?


Solution

  • I guess you are missing SurfaceHolder.unlockCanvasAndPost at the end