Reputation: 165
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!
Upvotes: 7
Views: 1783
Reputation: 9282
My experiences on Android 11.
Have to request ACCESS_MEDIA_LOCATION at runtime too.
The serving app should have 'all files access' in order for the receiving app to read lat, lon from exif.
If the serving app has all files access it does not need the MediaStore.setRequireOriginal to read lat,lon itself from file.
(I never used MediaStore.setRequireOriginal but will investigate now).
Upvotes: 1