首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

解决photo 过大内存溢出有关问题

2012-08-24 
解决photo 过大内存溢出问题{Uri thumbUri ContentUris.withAppendedId(PHOTO_CONTENT_URI,image)Parce

解决photo 过大内存溢出问题

{Uri thumbUri = ContentUris.withAppendedId(PHOTO_CONTENT_URI,image);ParcelFileDescriptor pfdInput;try {BitmapFactory.Options options = new BitmapFactory.Options();options.inDither = false;options.inPreferredConfig = Bitmap.Config.ARGB_8888;options.inSampleSize = 10;pfdInput = getContentResolver().openFileDescriptor(thumbUri, "r");bitmap = BitmapFactory.decodeFileDescriptor(pfdInput.getFileDescriptor(), null, options);pfdInput.close();} catch (FileNotFoundException ex) {Log.e(Tag, "couldn't open thumbnail " + thumbUri + "; "+ ex);} catch (IOException ex) {Log.e(Tag, "couldn't open thumbnail " + thumbUri + "; "+ ex);} catch (NullPointerException ex) {// we seem to get this if the file doesn't exist anymoreLog.e(Tag, "couldn't open thumbnail " + thumbUri + "; "+ ex);} catch (OutOfMemoryError ex) {Log.e(Tag, "failed to allocate memory for thumbnail "+ thumbUri + "; " + ex);}}

热点排行