软件在上传头像的时候有个图片剪切功能,本来一直没有问题的,后来公司有个同事买了部nexus手机,运行后发现图片剪切后崩溃,后来发现问题并解决

在这里记录一下

 

public static Bitmap getImageBitmap(Context context,Intent intent) {

Bitmap bitmap=null;

if (intent.getExtras()!=null) {

bitmap = (Bitmap) intent.getExtras().get("data");

}else {

Uri uri = intent.getData();

LogUtil.i("aaa", uri.toString());

try {

bitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri));

catch (FileNotFoundException e) {

e.printStackTrace();

return null;

}

 

}

return bitmap;

 

}

 返回值intent中是由路径的,不过是在data和extras中放着呢,所以判断是在哪里放着就好