android照片相机拍照和本地照片选择会出现问题。
对于本地照片选择,android 4.0和android4.4路径选择不同
4.4获取图片方式:Uri selectedImage = data.getData();
String imagePath = ImageTools.getPath(this, selectedImage); // 获取图片的绝对路径
newUri = Uri.parse("file:///" + imagePath); // 将绝对路径转换为URL
4.0获取newUri = data.getData();
获取到的图片之后,我们一般是用photo = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));来获取图片
但是测试了所有之后,小米手机却报了内存溢出,这里我们要加一下改变
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Config.RGB_565;
bitmap=BitmapFactory.decodeStream(getContentResolver().openInputStream(newUri),null,options);
这样就解决了oom问题了。