fix a crash in MediaUtils

This commit is contained in:
Conny Duck 2018-02-25 15:46:32 +01:00
parent 49a74f57a5
commit d5ed2f9a40

View file

@ -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();