找不到用户0的提供者;期望为此授权机构找到有效的ContentProvider

时间:2018-11-09 10:08:52

标签: android

我正在尝试使用

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

1 个答案:

答案 0 :(得分:1)

如果您说imageUrifile:///storage/emulated/0/DCIM/Camera/IMG_20181109_144042.jpg,则不应致电context.getContentResolver().notifyChange(imageUri, null);notifyChange()是:

  • ContentProvider实现使用(不是),并且
  • 是用于content Uri值(不是)