igreenwood / SimpleCropView

A simple image cropping library for Android.
MIT License
2.48k stars 465 forks source link

Loading images from Downloads folder causes IllegalArgumentException on Android 9 and above and is not working #151

Open hidekisdev opened 3 years ago

hidekisdev commented 3 years ago

Android 9 and above, loading images in Downloads folder causes IllegalArgumentException and fails. In Utils.java, getDataColumn method below fails.

      // DownloadsProvider
      else if (isDownloadsDocument(uri)) {
        final String id = DocumentsContract.getDocumentId(uri);
        // String "id" may not represent a valid Long type data, it may equals to
        // something like "raw:/storage/emulated/0/Download/some_file" instead.
        // Doing a check before passing the "id" to Long.valueOf(String) would be much safer.
        if (RawDocumentsHelper.isRawDocId(id)) {
          filePath = RawDocumentsHelper.getAbsoluteFilePath(id);
        } else {
          final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
          filePath = getDataColumn(context, contentUri, null, null);
        }
      }

I received the following message: java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/5

Any solution / guidance would be appreciated.