通过 Intent 共享照片时删除 EXIF 位置数据

EXIF location data removed when sharing photo via Intent(通过 Intent 共享照片时删除 EXIF 位置数据)
本文介绍了通过 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 位置数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)