title: Trying to create an efficient infinite looping frame animation routine for Android
body: <p>Since AnimationDrawable's memory blows up after a few images, I needed to write my own.  Google has some demonstrations regarding efficient frame animations, but it is very complicated(needlessly?).  </p>
  
  <p>Here is my initial approach, can I get some experts/smart ppl to chime in?</p>
  
  <ol>
  <li>Create a Handler on the UI Thread.</li>
  <li>create runables (A) for the handler.</li>
  <li>inside the runables (A), I create AsyncTasks for each frame.</li>
  <li>each AsyncTask is run using PostDelay to achieve desired frame rate.</li>
  <li>the target ImageVew is set wigh the new frame from the AsyncTask.</li>
  </ol>
  
  <p>Here is the code:</p>
  
  <pre><code>private void addTask(Handler handler, final String animationName, final int frameNumber, final AsyncTaskLoadBitmap asyncLoadBitmap, int frameIndex) {
      Runnable runnable = new Runnable() {
          @Override
          public void run() {
              int frameIdentifier = getResources().getIdentifier(animationName, "drawable", getPackageName());
              Log.v("Runable","adding name");
              new AsyncTaskLoadBitmap(imageView,thisActivity).execute(frameIdentifier);
          }
      };
  
      boolean done =  handler.postDelayed(runnable,100 + (100 * frameIndex));
      Log.v("PostDelayed","Done");
  }
  </code></pre>
  
  <p>The problem I'm having is making it loop and a way to stopping the loop. </p>
  
  <p>What could be a better approach?</p>