过滤内置图库以仅显示带有GeoTag(纬度和经度)的图片

时间:2013-12-22 12:34:35

标签: android image latitude-longitude android-gallery geotagging

我正在做一个让用户从内置图库中选择图像的应用程序。

到目前为止一直这么好.. 问题是,我需要向用户仅显示其中包含GeoTag的照片。

换句话说,我需要过滤内置图库显示,以便仅显示其中包含经度和纬度MetaData的图像,而不显示手机中的所有其他图片

这是一个简单的图像选择器代码:

private void pickPlace()
{
    Intent in = new Intent(
    Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);      
    startActivityForResult(in, RESULT_LOAD_IMAGE);      
}

//We Get The Selected Image From Gallery And Display It To User..
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
     super.onActivityResult(requestCode, resultCode, data);

     try {
        if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
             Uri selectedImage = data.getData();//URI for the picture
             String[] filePathColumn = { MediaStore.Images.Media.DATA };

             Cursor cursor = getContentResolver().query(selectedImage,
                     filePathColumn, null, null, null);
             cursor.moveToFirst();

             int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
             String picturePath = cursor.getString(columnIndex);
             cursor.close(); 

             //Load The Image Into Main Screen
             adjustImage(picturePath);

             //We get The Coordinates Back to 0
             mLongitude = (float) 0.0;
             mLatitude = (float) 0.0;
             mAddress = "";                              

         }
    } catch (NullPointerException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

这很好用,现在我需要找到如何过滤和仅显示纬度和经度的图像。 并隐藏所有其他图像。

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以从文件名创建 ExifInterface ,然后调用 getLatLong()获取坐标信息。 简单的IF条件可以检查文件中是否存在GeoLocation数据。

Read here

祝你好运!