I have recently switched my app to Scoped Storage. However, I have noticed that when I share an image from within the app (via an Intent), the GPS location data is removed from the image's Exif metadata. I am aware that Scoped Storage has some restrictions on accessing the Exif location data of an image and I am aware about the permission <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
, however adding this permission does not seem to have any effect when sharing the image. Any idea how to share images via Intent while retaining the location data in the image's Exif data?
Here is my code:
val imageUri = mediaList[photo_view_pager.currentItem].uri
val intent = Intent().apply {
val mediaType = MimeTypeMap.getSingleton()
.getMimeTypeFromExtension("jpg")
putExtra(Intent.EXTRA_STREAM, imageUri)
type = mediaType
action = Intent.ACTION_SEND
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
}
startActivity(Intent.createChooser(intent, getString(R.string.share_hint)))
Thanks a lot in advance for any help!
MediaStore.setRequireOriginal(photoUri)
and a content resolver, however the location is still not included in the photo when shared. I have also tried to amend the initial Uri used for sharing tophotoUri = MediaStore.setRequireOriginal(photoUri)
, however this will cause the photo not to be loaded into the third-party messaging app or causes a crash. – HerrenphotoUri = MediaStore.setRequireOriginal(photoUri)
You did that in the serving app? Did you also try in receiving app? – Costin