我只是想知道android 5.0.1和5.0.2之间有什么不同。 因为我的应用程序在5.0.2中运行完美但我在android 5.0.1中有问题。
在我的代码中查看我在if子句中检查设备的版本,但它无法从5.0.1识别5.0.2。
public static Bitmap downSampleBitmap(Uri uri, Activity act, Boolean needRotate) {
DisplayMetrics displaymetrics = new DisplayMetrics();
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
Resources r = act.getResources();
int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
50, r.getDisplayMetrics()); // 50: magic num
int targetWidth = displaymetrics.heightPixels;
int targetHeight = displaymetrics.widthPixels - px;
Bitmap resizedBitmap = decodeSampledBitmap(uri, targetWidth, targetHeight, act);
Bitmap returnBitmap = null;
ExifInterface exif;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
try {
exif = new ExifInterface(uri.toString());
int orient = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
rotateBitmap(returnBitmap,orient);
returnBitmap = returnBitmap == null ? resizedBitmap : returnBitmap;
} catch (IOException e) {
Log.v(TAG, "not found file at downsample");
e.printStackTrace();
}
} else {
try {
float degree = 0;
exif = new ExifInterface(uri.toString());
int orient = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
if (resizedBitmap != null && needRotate) {
degree = getDegree(orient);
if (degree != 0) {
returnBitmap = createRotatedBitmap(resizedBitmap, degree);
}
returnBitmap = returnBitmap == null ? resizedBitmap : returnBitmap;
}
} catch (IOException e) {
Log.v(TAG, "not found file at downsample");
e.printStackTrace();
}
}
return returnBitmap;
}