I'm trying to retrieve longitude and latitude values from geotagged images using android.media.ExifInterface library. However, getLatLong always returns false although the image is geotagged. This is my code :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button galleryButton = (Button) findViewById(R.id.galleryButton);
galleryButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent pickPhoto = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(pickPhoto , 1);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode) {
case 0:
if(resultCode == RESULT_OK){
Uri selectedImage = imageReturnedIntent.getData();
ExifInterface exif = new ExInterface(selectedImage.getPath());
float[] latlong = null;
bool result = exif.getLatLong(latlong);
}
break;
}
}
As you can see, I'm initializing exif object with the path from returned URI and it contains path like "/external/images/media/2330". When I call getLatLong, it always returns false. I have also tried the example from this page, but still does not work. Any help would be appreciated.
Galaxy S6 Edge Android SDK Version 25