Filter built-in gallery to show only pictures with GeoTag (Latitude and Longitude)

830 Views Asked by At

Im doing an app that let the user pick an image from the built-in gallery.

so far so good.. The thig is,I need to show the user only photos which has GeoTags in it.

In other words, I need to filter the built-in gallery display to show only images which has Longitude and Latitude MetaData in them and NOT show all the other pictures in my phone

Here is a simple image picker code:

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();
    }
}

This works good, Now I need to find how to filter and show only images with Latitude and Longitude.. and hide all the other images.

Thank You!

1

There are 1 best solutions below

2
On

You can create an ExifInterface from the file name and then call getLatLong() for coordinate information. A simple IF condition can check if there is GeoLocation data in the file.

Read here

Good luck!