fix a crash in MediaUtils
This commit is contained in:
parent
49a74f57a5
commit
d5ed2f9a40
1 changed files with 6 additions and 1 deletions
|
@ -70,7 +70,12 @@ public class MediaUtils {
|
||||||
public static long getMediaSize(@NonNull ContentResolver contentResolver, @Nullable Uri uri) {
|
public static long getMediaSize(@NonNull ContentResolver contentResolver, @Nullable Uri uri) {
|
||||||
if(uri == null) return MEDIA_SIZE_UNKNOWN;
|
if(uri == null) return MEDIA_SIZE_UNKNOWN;
|
||||||
long mediaSize;
|
long mediaSize;
|
||||||
Cursor cursor = contentResolver.query(uri, null, null, null, null);
|
Cursor cursor;
|
||||||
|
try {
|
||||||
|
cursor = contentResolver.query(uri, null, null, null, null);
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
return MEDIA_SIZE_UNKNOWN;
|
||||||
|
}
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE);
|
int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE);
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
|
|
Loading…
Reference in a new issue