简体   繁体   English

Android从内容URI获取EXIF数据

[英]Android get EXIF data from content URI

I'm trying to get exif data of a picture I take. 我正在尝试获取我拍摄的照片的exif数据。 However ExifInterface either takes a file path that I cannot give it since it's a "content" resource, or an InputStream but this works only for API 24+ (which I cannot allow). 但是,ExifInterface要么采用我无法提供的文件路径,因为它是“内容”资源,或者是InputStream,但这仅适用于API 24+(我不能允许)。 Do you know of any other options I could retrieve the orientation of my pic with? 你知道我可以检索我的照片方向的任何其他选项吗?

However ExifInterface either takes a file path that I cannot give it since it's a "content" resource, or an InputStream but this works only for API 24+ (which I cannot allow) 但是,ExifInterface要么采用我无法提供的文件路径,因为它是“内容”资源,或者是InputStream,但这仅适用于API 24+(我不能允许)

android.support.media.ExifInterface supports InputStream , works on older devices (since it comes from the Android Support libraries), and is not the security-bug-riddled android.media.ExifInterface that nobody should be using. android.support.media.ExifInterface支持InputStream ,适用于较旧的设备(因为它来自Android支持库),并不是没有人应该使用的安全漏洞的android.media.ExifInterface

Solved using the support library: 使用支持库解决:

  • add compile 'com.android.support:exifinterface:25.1.1' to your build.gradle file 将compile'c​​om.android.support:exifinterface:25.1.1'添加到build.gradle文件中
  • use class android.support.media.ExifInterface instead of android.media.ExifInterface 使用类android.support.media.ExifInterface而不是android.media.ExifInterface

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM