822 private boolean processImageFile(String path) {
823 try {
824 mBitmapOptions.outWidth = 0;
825 mBitmapOptions.outHeight = 0;
826 BitmapFactory.decodeFile(path, mBitmapOptions);
827 mWidth = mBitmapOptions.outWidth;
828 mHeight = mBitmapOptions.outHeight;
829 return mWidth > 0 && mHeight > 0;
830 } catch (Throwable th) {
831 // ignore;
832 }
833 return false;
834 }
http://androidxref.com/9.0.0_r3/xref/frameworks/base/media/java/android/media/MediaScanner.java#822
479 public static Bitmap decodeFile(String pathName, Options opts) {
480 validate(opts);
481 Bitmap bm = null;
482 InputStream stream = null;
483 try {
484 stream = new FileInputStream(pathName);
485 bm = decodeStream(stream, null, opts);
486 } catch (Exception e) {
487 /* do nothing.
488 If the exception happened on open, bm will be null.
489 */
490 Log.e("BitmapFactory", "Unable to decode stream: " + e);
491 } finally {
492 if (stream != null) {
493 try {
494 stream.close();
495 } catch (IOException e) {
496 // do nothing here
497 }
498 }
499 }
500 return bm;
501 }
如上代码,BitmapFactory.decodeFile会返回一个Bitmap对象,但在上面的代码中,没有对返回值做处理,会存在Bitmap内存泄露吗?
需要增加一个接收返回值Bitmap的处理,在finally中再执行recycle处理吗?