I know how to get the current GPS location of a mobile phone. I also know how to save the GPS location to the photo when you take it. (Camera option Samsung galaxy s2).
But how can I get the GPS location of that photo (later)? When I open the photo on the computer, I can see the GPS location data, but got no idea how to extract them later in android. So could someone put me in the good direction? To make question more clearly: How can I get the GPS location of a photo that is already taken?
Thanks already, Bigflow
josnidhin made this answer possible, so be sure to give him credit too :)
Here we go:
import android.media.ExifInterface;
exif = new ExifInterface(filePath);
String lat = ExifInterface.TAG_GPS_LATITUDE;
String lat_data = exif.getAttribute(lat);
After that, lat_data will be something like: 51/1,58/1,32/1
This is the same as: 51, 58, 32. (typing this in google maps will give bad result)
To get the gps coordinates of this you need to do some math, here it comes:
This is also the same when you with TAG_GPS_LONGITUDE
I think the geotag is in the EXIF data of the photo taken. Find a suitable EXIF data reader which will help you extract the data you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With