解决photo 过大内存溢出有关问题
解决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 anymore Log.e(Tag, "couldn't open thumbnail " + thumbUri + "; " + ex); } catch (OutOfMemoryError ex) { Log.e(Tag, "failed to allocate memory for thumbnail " + thumbUri + "; " + ex); } }