单击相机中的图像后出现内存不足错误。获取位图的代码是:
public void grabImage(ImageView imageView) {
this.getContentResolver().notifyChange(mImageUri, null);
ContentResolver cr = this.getContentResolver();
Bitmap bitmap = null;
try {
//getting crash on this line
bitmap = android.provider.MediaStore.Images.Media.getBitmap(cr, mImageUri);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 50 / 100, byteArrayOutputStream);
getImageUri(this, bitmap);
imageView.setImageBitmap(bitmap);
} catch (Exception e) {
Toast.makeText(this, "Failed to load",Toast.LENGTH_SHORT).show();
Log.d(TAG, "Failed to load", e);
}catch (OutOfMemoryError e){
e.printStackTrace();
}
}