title: Starting an AnimationDrawable in Android
body: <p>Where should I start an <code>AnimationDrawable</code> that needs to animate when the activity is shown?</p>
  
  <p>The developer guide <a href="http://developer.android.com/guide/topics/graphics/2d-graphics.html#frame-animation" rel="noreferrer">recommends</a> using <code>onWindowFocusChanged</code>, but this isn't always called when the activity is part of a <code>TabHost</code>. </p>
  
  <p>I quote:</p>
  
  <blockquote>
    <p>It's important to note that the
    start() method called on the
    AnimationDrawable cannot be called
    during the onCreate() method of your
    Activity, because the
    AnimationDrawable is not yet fully
    attached to the window. If you want to
    play the animation immediately,
    without requiring interaction, then
    you might want to call it from the
    onWindowFocusChanged() method in your
    Activity, which will get called when
    Android brings your window into focus.</p>
  </blockquote>