Looking at the storage access changes introduced in Android Q here, location informations are now redacted by default.
Google asks us to call setRequireOriginal() on the "MediaStore" object with the media's uri as a parameter. This works when you fetch medias one by one, but what about when we query the ContentResolver for the whole gallery?
See this sample:
String[] projection = {
MediaStore.Files.FileColumns._ID,
MediaStore.Files.FileColumns.DATA,
MediaStore.Files.FileColumns.MEDIA_TYPE,
MediaStore.Images.Media.DATE_TAKEN,
MediaStore.Images.Media.WIDTH,
MediaStore.Images.Media.HEIGHT,
MediaStore.Images.Media.LATITUDE, // <----- THIS
MediaStore.Images.Media.LONGITUDE, // <----- THIS
MediaStore.Images.Media.MIME_TYPE,
};
String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "="
+ MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE;
Uri queryUri = MediaStore.Files.getContentUri("external");
Cursor cursor = null;
MediaStore a ;
try {
cursor = context.getContentResolver().query(queryUri, projection, selection,
null, MediaStore.Images.Media.DATE_TAKEN + " DESC");
}
catch (NullPointerException ex){
}
Starting Q the latitude and longitude are always set to 0. Is there a way to get the location data for a batch of medias assuming the ACCESS_MEDIA_LOCATION permission is added in the Manifest?
from Android Q: fetch the gallery via MediaStore with location information
No comments:
Post a Comment