我试图获取图像的 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/