我正在尝试使用:
public int getCameraPhotoOrientation(Context context, Uri imageUri, String imagePath){
int rotate = 0;
try {
context.getContentResolver().notifyChange(imageUri, null);
File imageFile = new File(imagePath);
ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
Timber.d("270");
break;
case ExifInterface.ORIENTATION_ROTATE_180:
Timber.d("180");
break;
case ExifInterface.ORIENTATION_ROTATE_90:
Timber.d("90");
break;
}
} catch (Exception e) {
e.printStackTrace();
}
return rotate;
}
我正在传递URL:
file:///storage/emulated/0/DCIM/Camera/IMG_20181109_144042.jpg
我遇到错误:
java.lang.SecurityException: Failed to find provider for user 0; expected to find a valid ContentProvider for this authority
答案 0 :(得分:1)
如果您说imageUri
是file:///storage/emulated/0/DCIM/Camera/IMG_20181109_144042.jpg
,则不应致电context.getContentResolver().notifyChange(imageUri, null);
。 notifyChange()
是:
ContentProvider
实现使用(不是),并且content
Uri
值(不是)