GPS经度和纬度来自地理标记的照片

时间:2011-03-03 17:15:36

标签: android gps photo latitude-longitude

我在手机相机中启用了地理标记功能。它保存了纬度和经度信息(我已经检查过)。我正试图像这样阅读它

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标签并将它们存储在数据库中。但是,由于某种原因,不存储纬度和经度字段。

1 个答案:

答案 0 :(得分:1)

我建议您使用ExifInterface