|
@@ -37,12 +37,25 @@ public class PathResolver {
|
37
|
37
|
}
|
38
|
38
|
// DownloadsProvider
|
39
|
39
|
else if (isDownloadsDocument(uri)) {
|
|
40
|
+ try {
|
|
41
|
+ final String id = DocumentsContract.getDocumentId(uri);
|
|
42
|
+ //Starting with Android O, this "id" is not necessarily a long (row number),
|
|
43
|
+ //but might also be a "raw:/some/file/path" URL
|
|
44
|
+ if (id != null && id.startsWith("raw:/")) {
|
|
45
|
+ Uri rawuri = Uri.parse(id);
|
|
46
|
+ String path = rawuri.getPath();
|
|
47
|
+ return path;
|
|
48
|
+ }
|
|
49
|
+ final Uri contentUri = ContentUris.withAppendedId(
|
|
50
|
+ Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
|
40
|
51
|
|
41
|
|
- final String id = DocumentsContract.getDocumentId(uri);
|
42
|
|
- final Uri contentUri = ContentUris.withAppendedId(
|
43
|
|
- Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
|
44
|
|
-
|
45
|
|
- return getDataColumn(context, contentUri, null, null);
|
|
52
|
+ return getDataColumn(context, contentUri, null, null);
|
|
53
|
+ }
|
|
54
|
+ catch (Exception ex) {
|
|
55
|
+ //something went wrong, but android should still be able to handle the original uri by returning null here (see readFile(...))
|
|
56
|
+ return null;
|
|
57
|
+ }
|
|
58
|
+
|
46
|
59
|
}
|
47
|
60
|
// MediaProvider
|
48
|
61
|
else if (isMediaDocument(uri)) {
|