title: Multiple canvases on Live Wallpaper (one moving, one stable). How?
body: <p>How can I draw multiple canvases on Live Wallpaper?</p>
  
  <p>I want a live wallpaper having a <strong>background image</strong> (bitmap), and on the image there would be <strong>an object</strong>, which follows your finger. But I can't draw more than one canvas.</p>
  
  <p>I've already went through Google, but I didn't find anythink helpful.</p>
  
  <p>Is there any way to produce this?</p>
  
  <p>Here's my (not working) code for this:</p>
  
  <pre><code>package i.need.some.help;
  
  import android.content.res.Resources;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.graphics.Canvas;
  import android.graphics.Paint;
  import android.service.wallpaper.WallpaperService;
  import android.view.MotionEvent;
  import android.view.SurfaceHolder;
  
  public class NewMyWallpaperService extends WallpaperService {
  
      @Override
      public Engine onCreateEngine() {
          return new CubeEngine();
      }
  
      class CubeEngine extends Engine {
          private final Paint mPaint = new Paint();
          private final Paint myPaint = new Paint();
          private float mTouchX = 0;
          private float mTouchY = 0;
  
          Bitmap movingObject = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
          final SurfaceHolder holder = getSurfaceHolder();
          int height = Resources.getSystem().getDisplayMetrics().heightPixels;
          int width = Resources.getSystem().getDisplayMetrics().widthPixels;
          Bitmap backroundIMG = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round);
  
          CubeEngine() {
              setBackground();
          }
  
          @Override
          public void onCreate (SurfaceHolder surfaceHolder) {
              super.onCreate(surfaceHolder);
              // Touch event handle alert
              setTouchEventsEnabled(true);
          }
  
          @Override
          public void onSurfaceCreated(SurfaceHolder holder) {
              super.onSurfaceCreated(holder);
          }
  
          @Override
          public void onTouchEvent (MotionEvent event) {
              super.onTouchEvent(event);
  
              if (event.getAction() == MotionEvent.ACTION_UP) {
                  mTouchX = event.getX();
                  mTouchY = event.getY();
              } else {
                  mTouchX = event.getX();
                  mTouchY = event.getY();
              }
              drawFrame();
          }
  
          void drawFrame() {
              Canvas c = null;
              try {
                  c = holder.lockCanvas();
                  if (c !=null) {
                      c.save();
                      c.drawBitmap(movingObject, mTouchX-(movingObject.getWidth()/2), mTouchY-(movingObject.getHeight()/2), mPaint);
                      c.restore();
                  }
              } finally {
                  if (c != null) {
                      holder.unlockCanvasAndPost(c);
                  }
              }
          }
          final void setBackground() {
              Canvas ca = null;
              try {
                  ca = holder.lockCanvas();
                  if (ca !=null) {
                      ca.save();
                      ca.drawColor(0xffa8a8a8);
                      ca.drawBitmap(backroundIMG, height/2, width/2, myPaint);
                      ca.restore();
                  }
              } finally {
                  if (ca != null) {
                      holder.unlockCanvasAndPost(ca);
                  }
              }
          }
      }
  }
  </code></pre>