【问题标题】:Photo in gallery is not timestamped when created by Intent with MediaStore.ACTION_IMAGE_CAPTURE action当 Intent 使用 MediaStore.ACTION_IMAGE_CAPTURE 操作创建时,图库中的照片没有时间戳
【发布时间】: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


    【解决方案1】:

    如何将图像存储在图库中?以下内容会有所帮助吗? http://developer.android.com/training/camera/photobasics.html#TaskGallery

    【讨论】:

    • 看完那篇文章后说实话,我很惊讶他们竟然把这些存到了画廊里!无论如何,这解决了问题,非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2011-01-18
    • 2016-12-18
    • 1970-01-01
    • 2012-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多