josnidhin made this answer possible, so be sure to also give him credit :)
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 look something like this: 51 / 1.58 / 1.32 / 1
This is the same as: 51, 58, 32. (typing this on google maps, you will get a bad result)
To get the gps coordinates of this, you need to do some math, here it is:
- Calculate the total number of seconds:
58'32 "= (58 * 60 + 32) = 3512 seconds. - The fractional part is the total number of seconds divided by 3600:
3512/3600 = ~ 0.975556 - Add fractional degrees to integer degrees to get the final result:
51 + 0.975556 = 51.975556 - If this is the west longitude coordinate, deny the result. (this is not this time)
- answer: 51.975556
This is the same when you are with TAG_GPS_LONGITUDE
source share