I have a method that, given a Uri, should retrieve the location data from that photo. However, all I am getting is zeros from the cursor.GetDouble(latitudeColumnIndex);
method
What am I missing?
private void GetImageLocation(Uri uri)
{
string[] projection =
{
MediaStore.Images.Media.InterfaceConsts.Latitude,
MediaStore.Images.Media.InterfaceConsts.Longitude,
};
using (ICursor cursor = ContentResolver.Query(uri, projection, null, null, null))
{
if (cursor.MoveToFirst())
{
int latitudeColumnIndex = cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Latitude);
int longitudeColumnIndex = cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Longitude);
if (latitudeColumnIndex == -1 || longitudeColumnIndex == -1)
{
_newPhoto.Latitude = 0;
_newPhoto.Longitude = 0;
}
_newPhoto.Latitude = cursor.GetDouble(latitudeColumnIndex);
_newPhoto.Longitude = cursor.GetDouble(longitudeColumnIndex);
}
else
{
_newPhoto.Latitude = 0;
_newPhoto.Longitude = 0;
}
cursor.Close();
}
}