I am just implementing the new Android 13 photo picker and I simply cannot get the EXIF location of the selected photos.
Intent intent = new Intent(MediaStore.ACTION_PICK_IMAGES);
intent.setType("image/*");
intent.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, 5);
startActivityForResult(intent, SELECT_NEW_PICKER_REQUEST);
... getting the photos and checking for EXIF location:
for (int i = 0; i < returnedIntent.getClipData().getItemCount(); i++) {
Uri uri = returnedIntent.getClipData().getItemAt(i).getUri();
InputStream input = getContentResolver().openInputStream(uri);
ExifInterface exifInterface = new ExifInterface(input);
// Works!
String dateTime = exifInterface.getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL);
// NULL
String latDest = exifInterface.getAttribute(ExifInterface.TAG_GPS_DEST_LATITUDE);
// Not set
String lat = exifInterface.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
// NULL
double[] latLng = exifInterface.getLatLong();
}
I requested the android.permission.ACCESS_MEDIA_LOCATION
and the android.permission.READ_MEDIA_IMAGES
, they are both granted, but it still does not work!
Any ideas?
Tobias
UPDATE
It seems Google doesn't allow it on purpose ! https://issuetracker.google.com/issues/243294058