【问题标题】:Failed to find provider for user 0; expected to find a valid ContentProvider for this authority找不到用户 0 的提供者;预计会为此权限找到有效的 ContentProvider
【发布时间】:2018-11-09 10:08:52
【问题描述】:

我正在尝试使用

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

【问题讨论】:

  • 你是否在 manifest 中添加了读取权限?
  • 什么是读取权限.. 因为我没有使用自定义内容提供程序

标签: android


【解决方案1】:

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

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

【讨论】:

  • 那么应该叫什么?
  • 那么应该叫什么?
  • @afhamu:没什么。老实说,我不知道为什么 OP 在他们的原始样本中有这条线。
猜你喜欢
  • 2021-03-06
  • 1970-01-01
  • 1970-01-01
  • 2021-04-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-17
  • 2020-03-01
相关资源
最近更新 更多