recycle Bitmaps - Android Graphics

Android examples for Graphics:Bitmap Recycle

Description

recycle Bitmaps

Demo Code


//package com.java2s;

import android.graphics.Bitmap;

public class Main {
    public static void recycleBitmaps(Bitmap bitmaps[]) {
        if (bitmaps != null) {
            for (Bitmap b : bitmaps) {
                recycleBitmap(b);//from  w  w  w.j a va  2 s.c om
            }

            bitmaps = null;
        }
    }

    public static void recycleBitmap(Bitmap b) {
        if (b != null && !b.isRecycled()) {
            b.recycle();
            b = null;
        }
    }
}

Related Tutorials