【发布时间】:2014-07-22 10:15:04
【问题描述】:
我认为这个问题已经在其他地方得到了回答,但我没有找到答案。
我正在通过我的应用程序拍摄照片,方法是生成图像 URI 并使用 MediaStore.ACTION_IMAGE_CAPTURE 启动一个活动作为这样的操作;
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);
myActivity.this.startActivityForResult(t, MY_PHOTO_REQUEST_CODE);
收到结果后,我获取文件路径并查看 exif 数据,如下所示;
Cursor cursor = activity.getContentResolver().query(mCapturedImageURI, projection, null, null, null);
if(cursor.moveToFirst())
{
int column_index_data = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
//Get file path from last stored photo
capturedImageFilePath = new String(cursor.getString(column_index_data));
}
cursor.close();
ExifInterface e = new ExifInterface(capturedImageFilePath);
String dateTime = e.getAttribute(ExifInterface.TAG_DATETIME);
exifData 包含正确的日期时间,但是如果我查看图库中的照片详细信息,照片的日期是“01/01/1970 01:00”。我不明白为什么会这样。
注意:为清楚起见,我省略了异常处理和其他我认为不相关的代码。我还确保不会在我不知情的情况下抛出异常。
【问题讨论】:
标签: android timestamp gallery photo exif