Android AnimationDrawable memory management
<p>I'm creating an android application &amp; it has background animations for each activity.
I used <code>AnimationDrawable</code> <code>setBackgroundResource(anim.xml)</code> to run the animation xml files and works fine.
problem is, when I test on devices,some devices gives me an <code>FATAL EXEPTION</code> telling that 
<code>bitmap size exeeds VM budget(out of memory)</code>.</p>

<p>so I surfed web and found some solutions like executing <code>animation.setCallbacks(null)</code> before 
run the animation,<a href="http://developer.android.com/training/displaying-bitmaps/load-bitmap.html" rel="nofollow">scaling down bitmaps</a>(programmatically) and resizing drawables.
I tried them but few devices which has low heap still gives the same error.</p>

<p>so I want to know am I doing something wrong or missing something?
is their any other solution to this problem?</p>

<pre><code>//animation
    private void animate() {
            imgView = (ImageView)findViewById(R.id.imageView1);
            imgView.setVisibility(ImageView.VISIBLE);
            imgView.setBackgroundResource(R.drawable.level_animation);

            frameAnimation =  (AnimationDrawable) imgView.getBackground();
            if (frameAnimation.isRunning()) {
               frameAnimation.stop();
            }
            else {
               frameAnimation.stop();
               frameAnimation.start();
            }
         } 

xml
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true" &gt;
       &lt;item android:drawable="@drawable/top_anim1" android:duration="200" /&gt;
       &lt;item android:drawable="@drawable/top_anim2" android:duration="200" /&gt;
       &lt;item android:drawable="@drawable/top_anim3" android:duration="200" /&gt;
       &lt;item android:drawable="@drawable/top_anim4" android:duration="200" /&gt;
       &lt;item android:drawable="@drawable/top_anim5" android:duration="200" /&gt;
&lt;/animation-list&gt;
</code></pre>
