title: live wallpaper with images
body: <p>(sorry for my Englih is not so good... hope you will understand me)</p>
  
  <p>My friend is a really good drawer. I would like to help him to be know as a good drawer by making him a live wallpaper animated with his drawings. </p>
  
  <p>I would like him to draw few frames and use these frames to make a live wallpaper by displaying them one after the other. </p>
  
  <p>I'm struggling so much to display one picture then wait a bit and display the next one. I'm quite sure that I can't succeed to do it because I don't use the right approach... </p>
  
  <p>This is what I have done until now :</p>
  
  <pre><code>public class Cercle extends WallpaperService
  {
  public void onCreate() 
  {
      super.onCreate();
  }
  
  public void onDestroy() 
  {
      super.onDestroy();
  }
  
  public Engine onCreateEngine() 
  {
      return new CercleEngine();
  }
  
  class CercleEngine extends Engine 
  {
      public Bitmap image1, image2, image3;
  
      CercleEngine() 
      {       
          image1 = BitmapFactory.decodeResource(getResources(), R.drawable.img1);
          image2 = BitmapFactory.decodeResource(getResources(), R.drawable.img2);
          image3 = BitmapFactory.decodeResource(getResources(), R.drawable.img3); 
      }
  
      public void onCreate(SurfaceHolder surfaceHolder) 
      {
          super.onCreate(surfaceHolder);
      }
  
      public void onOffsetsChanged(float xOffset, float yOffset, float xStep, float yStep, int xPixels, int yPixels) 
      {
          drawFrame();
      }
  
      void drawFrame() 
      {
          final SurfaceHolder holder = getSurfaceHolder();
  
          Canvas c = null;
          try 
          {
              c = holder.lockCanvas();
              if (c != null) 
              {              
                   c.drawBitmap(image1, 0, 0, null);
                   c.drawBitmap(image2, 0, 0, null);
                   c.drawBitmap(image3, 0, 0, null);                   
              }
          } finally 
          {
              if (c != null) holder.unlockCanvasAndPost(c);
          }
      }
  }
  }
  </code></pre>
  
  <p>This code just display the pictures too quickly because I don't know how to wait between diplaying pictures...</p>
  
  <p>Can anyone give me some tips or show me some example of another solution ?</p>
  
  <p>Thanks so much !</p>
  
  <p><strong>UPDATE :</strong></p>
  
  <p>I got my problem resolved by adding a Runnable :</p>
  
  <pre><code>private final Runnable drawRunner = new Runnable() 
      {
          @Override
          public void run() {
              drawFrame();
          }
  
      };
  </code></pre>
  
  <p>and then by adding :</p>
  
  <pre><code>    handler.removeCallbacks(drawRunner);
          if (visible) 
          {
             handler.postDelayed(drawRunner, 1000); // delay 1 sec
          }
  </code></pre>
  
  <p>at the end of drawFrame().</p>
  
  <p>Hope this will help someone.</p>