Reputation: 610
I´m trying to run an app with several DrawableAnimation.
Structure
MainActivity - ButtonA - ButtonB - ButtonC - ButtonD - ButtonE - Button F
So, each button Start a Short DrawableAnimation, each animation has 30 to 50 images. I know it´s a little ambitious, but I´m sure there´s a way to do it.
Each Animation start with this code:
private void addListenerOnButton() {
view = (ImageView) findViewById(R.id.image);
button = (Button) findViewById(R.id.startanimation);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
frameAnimation.stop(); frameAnimation = null;
view.setBackgroundResource(R.drawable.animation01);
frameAnimation = (AnimationDrawable) view.getBackground();
frameAnimation.start();
I tried to clean memory with animation stop or animation null, but it doesn't work. I tried with bitmap recycle but, If the user wants to run an Animation more than one time it doesn't work cause recycle don't use it anymore. I know that garbage collector is not the way.
So, how can I run DrawableAnimation and Clean Memory after finish it, to avoid the Out of Memory error?
Upvotes: 0
Views: 124
Reputation: 321
for me this code works fine
largeHeap=true
you have to put in application tag of manifest
Upvotes: 1