fixed security exception when attempting to display image in notification
This commit is contained in:
parent
875f0b9943
commit
c7dea9dded
|
@ -413,11 +413,16 @@ public class FileBackend {
|
||||||
|
|
||||||
public static Uri getMediaUri(Context context, File file) {
|
public static Uri getMediaUri(Context context, File file) {
|
||||||
final String filePath = file.getAbsolutePath();
|
final String filePath = file.getAbsolutePath();
|
||||||
final Cursor cursor = context.getContentResolver().query(
|
final Cursor cursor;
|
||||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
try {
|
||||||
new String[] { MediaStore.Images.Media._ID },
|
cursor = context.getContentResolver().query(
|
||||||
MediaStore.Images.Media.DATA + "=? ",
|
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||||
new String[] { filePath }, null);
|
new String[]{MediaStore.Images.Media._ID},
|
||||||
|
MediaStore.Images.Media.DATA + "=? ",
|
||||||
|
new String[]{filePath}, null);
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
final int id = cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID));
|
final int id = cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID));
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
|
Loading…
Reference in New Issue