Bitmap and outOfMemory in android -


i have problem out of memory bitmap. code:

uri bitmappictureuri = intent.getparcelableextra(taskactivity.photo);             bitmap bitmap = null;              try {                 bitmap = mediastore.images.media.getbitmap(this.getcontentresolver(), bitmappictureuri);             } catch (filenotfoundexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             } catch (ioexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }              int nh = (int) (bitmap.getheight() * (512.0 / bitmap.getwidth()));             bitmappicture = bitmap.createscaledbitmap(bitmap, 512, nh, true);              picture.setimagebitmap(bitmappicture);             filename.settext(tnametext+"_"+getcurrenttime()); 

everything ok when change orientation outofmemory. how can solve problem? thinking softreference don't know how can use bitmap. idea?

recycle bitmap when start activity

    if(bitmap!=null){          bitmap.recycle();          bitmap=null;     } 

see also


Comments