android - 所有 ExifInterface 值返回 0 或 null

标签 android exif

我试图获取图像的 GPS 位置,但我得到的只是 null/0,我尝试从不同图像中获取其他 exif 信息,但结果仍然是 null/0

public void MarkGeoTagImage(String imagePath)
{
    try {
        ExifInterface exif = new ExifInterface(imagePath);
Toast.makeText(MainActivity.this, imagePath, Toast.LENGTH_LONG).show();
        Toast.makeText(MainActivity.this, exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE),Toast.LENGTH_LONG).show();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

第一个 toast 显示图像的绝对路径,如/storage/sdcard0/etp_images/test.jpg,但第二个 toast 仅显示 0 或 null 作为结果。

最佳答案

可能这不是一个解决方案,但我之前在 ExifInterface 方面遇到了一些问题。原始类 ExifInterface 有不同的错误。尝试使用此类的支持版本。就我而言,它解决了我的问题。 使用 Gradle 编译:com.android.support:exifinterface:25.1.0

关于android - 所有 ExifInterface 值返回 0 或 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42368235/

相关文章:

android - E/CameraService : Permission Denial: can't use the camera pid=9410, uid=10230 CameraFragment

android - 如何在我的文件管理器中显示 apk 图标

ios - 如何在不复制的情况下修改 iOS 中的图像元数据(EXIF)?

powershell - 将 EXIF DateTaken 设置为文件创建时间

swift - 使用 swift 4 检索 NSDictionary 值

Android 为图像文件创建自定义 Exif 属性

android - Firebase 重复文件构建错误

java - 向位图添加虚线边框

Android,在与 ImageView 的图像相同的 URL 处制作图像

vb.net - 在 vb.net 中更正图像方向服务器端