采取斜面设置日期使用ExifInterface在安卓/日期标签 [英] Cant set Date Taken/DateTime tag using the ExifInterface in Android

查看:355
本文介绍了采取斜面设置日期使用ExifInterface在安卓/日期标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经研究和尝试多种选择,试图得到这个工作,但我没有得到这个不幸的任何地方。

I've researched and tried numerous options to try and get this to work, but am not getting anywhere with this unfortunately.

我试图做的是从内部一个Android应用程序设置为JPEG的Exif数据中的拍摄日期标签(Tag_DateTime)什么。我已经有工作code设置纬度和经度的标签,但不能为我的生命得到拍摄日期标签设置。

What I am trying to do is set the Date Taken tag (Tag_DateTime) in a JPEG's Exif data from within an Android app. I already have working code to set the Latitude and Longitute tags, but cannot for the life of me get the Date taken tag to set.

下面是code:

SimpleDateFormat fmt_Exif = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
try {
    ExifInterface exif = new ExifInterface(filePhoto.getPath());

    // Set and save the GPS and time data
    exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, strLat);
    exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, strLong);
    exif.setAttribute(ExifInterface.TAG_DATETIME, fmt_Exif.format(locLatestLocation.getTime()));
    exif.saveAttributes();

} catch (IOException e) {
    e.printStackTrace();
}

  • locLatestLocation - 位置被用于获取毫秒的时间
  • fmt_Exif - 用毫秒时间格式化成的TAG_DateTime的Exif标签格式正确的SimpleDateFormat
  • strLat和放大器; strLong - 以正确的格式设置纬度和经度标记其他地方填充
  • 我在后读的地方,该标签必须写在毫秒格式,所以曾尝试过无济于事。 为了证实我的格式有什么实际存储,我阅读和输出从具有拍摄日期标签的JPEG文件未格式化标签,但输出是完全一样的格式是什么我写它仍然是标签和没有工作。

    I read in a post somewhere that the tag needs to be written in the milliseconds format, so have tried this too to no avail. In order to confirm my formatting with what is actually stored, I read and outputted the unformatted tag from a jpeg file which has the Date Taken tag, but the output is in exactly the same format as what I am writing to the tag and its still not working.

    这也可能是值得一提的是,我已经寻找到Sanselan类来做到这一点,因为例子更愿意尝试,并获得我的现有解决方案转变为一个完全不同的人之前的工作缺乏的复杂性和。

    It might also be worth mentioning that I have looking into the Sanselan class to do this, and due to the complexity and lack of examples would much rather try and get my existing solution working before changing to a completely different one.

    有没有人成功地做到这一点,如果让我在做什么错了?

    Has anyone managed to do this and if so what am I doing wrong??

    推荐答案

    Android的ExifInterface,烦人,将丢弃它认为是无效的任何数据。更糟糕的是,该文件甚至没有提及什么有效值可能。

    Android's ExifInterface, annoyingly, silently discards any data it deems to be invalid. Worse yet, the documentation doesn't even mention what valid values might be.

    我还发现,如果你指定一个EXIF属性,它的Andr​​oid想不通(IE:这不是ExifInterface的TAG_常量之一),它也将完全忽略它,也静静的失败

    I've also found that if you specify an EXIF attribute that Android can't figure out (IE: it's not one of ExifInterface's TAG_ constants), it will also completely ignore it, and also fail silently.

    这篇关于采取斜面设置日期使用ExifInterface在安卓/日期标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆