title: Android Live Wallpaper Animation
body: <p>What's the best way to display an animation as a live wallpaper? Right now I have a gif split into 11 pngs (one per frame) and then I just am doing</p>
  
  <pre><code>public Bitmap frame0;
  ArrayList&lt;Bitmap&gt; frameArray = new ArrayList&lt;Bitmap&gt;();
  frame0 = BitmapFactory.decodeResource(getResources(), R.drawable.nyancat0);
  frame0 = Bitmap.createScaledBitmap(frame0, minWidth, minHeight, true);
  frameArray.add(frame0);
  </code></pre>
  
  <p>Then I just use a For Loop to loop through the frames and draw them on a canvas</p>
  
  <pre><code>canvas.drawBitmap(frameArray.get(indexnumber), 0, 0, mPaint);
  </code></pre>
  
  <p>and then I just change my indexnumber++ unless it's 11, then I go back to 1.
  That works, but of course, storing that many Bitmaps is very memory inefficient. This stops me from doing multiple layers or other cool effects without lagging and battery drain. Is there a better way to display an animation on the Android Live wallpaper? I tried Movie for displaying the whole GIF but that's not supported for live wallpapers.</p>