我的手机摄像头中启用了地理标记。它保存经纬度信息(我已经检查过了)。我想这样读

import static android.provider.MediaStore.Images.ImageColumns.*;

Uri queryPhotoUri = ...; //uri of photo
String[] photoProjection = {LATITUDE,LONGITUDE,ORIENTATION,DESCRIPTION};

Cursor photoData = getContext().getContentResolver().query(
            queryPhotoUri, photoProjection, null, null, null);

int latIdx = photoData.getColumnIndex(LATITUDE);
int lngIdx = photoData.getColumnIndex(LONGITUDE);
int oriIdx = photoData.getColumnIndex(ORIENTATION);
int txtIdx = photoData.getColumnIndex(DESCRIPTION);

boolean latExists = !photoData.isNull(latIdx);
boolean lngExists = !photoData.isNull(lngIdx);
boolean oriExists = !photoData.isNull(oriIdx);
boolean txtExists = !photoData.isNull(txtIdx);

oriexists的计算结果为true,其余为false。为什么?图像内容提供商是将纬度和经度作为exif属性写入照片文件,还是将它们存储在其他地方?
另外,我正在尝试将照片的描述写入“描述”列,但未保存。描述存储在哪里?
编辑:越来越陌生了。我已经检查了框架源代码,mediaprovider类从照片中读取exif标记并将它们存储在数据库中。但是,由于某些原因,纬度和经度字段没有存储。

最佳答案

我建议您使用ExifInterface

08-03 18:44