How to get the latitude and longitude of an image in sdcard to my application?

后端 未结 3 995
花落未央
花落未央 2020-12-14 13:04

From my application I can open gallery. Is there any way to get latitude and longitude of any selected image in gallery to my application?

3条回答
  •  执笔经年
    2020-12-14 13:54

    the exif.getLatLong(float[]) is now deprecated, you can use a better method which returns a double[] :

    ExifInterface exifInterface = new ExifInterface(file);
    double[] latlng = exifInterface.getLatLong();
    if (latlng != null) {
        Double currentLatitude = latlng[0];   
        Double currentLongitude = latlng[1];
        Log.d("Debug", "Exif : latitude: " + currentLatitude + ", longitude: " + currentLongitude)  
    }
    

    Happy coding.

提交回复
热议问题