EXIF location data removed when sharing photo via Intent(通过 Intent 共享照片时删除 EXIF 位置数据)
问题描述
我最近将我的应用程序切换到了 Scoped Storage.但是,我注意到,当我从应用程序内(通过 Intent)共享图像时,GPS 位置数据会从图像的 Exif 元数据中删除.我知道 Scoped Storage 对访问图像的 Exif 位置数据有一些限制,并且我知道权限 <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>
,但是添加此权限似乎在共享图像时没有任何效果.知道如何通过 Intent 共享图像,同时将位置数据保留在图像的 Exif 数据中吗?
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?
这是我的代码:
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!
推荐答案
我在 Android 11 上的体验.
My experiences on Android 11.
也必须在运行时请求 ACCESS_MEDIA_LOCATION.
Have to request ACCESS_MEDIA_LOCATION at runtime too.
服务应用应具有所有文件访问权限",以便接收应用从 exif 读取纬度、经度.
The serving app should have 'all files access' in order for the receiving app to read lat, lon from exif.
如果服务应用程序可以访问所有文件,则不需要 MediaStore.setRequireOriginal 从文件中读取 lat,lon 本身.
If the serving app has all files access it does not need the MediaStore.setRequireOriginal to read lat,lon itself from file.
(我从未使用过 MediaStore.setRequireOriginal,但现在将进行调查).
(I never used MediaStore.setRequireOriginal but will investigate now).
这篇关于通过 Intent 共享照片时删除 EXIF 位置数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:通过 Intent 共享照片时删除 EXIF 位置数据


基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01