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

后端 未结 3 999
花落未央
花落未央 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:41

    You can actually use a "buildin" function:

    ExifInterface exif = new ExifInterface(path);
    float[] latLong = new float[2];
    boolean hasLatLong = exif.getLatLong(latLong)
    if (hasLatLong) {
        System.out.println("Latitude: " + latLong[0]);
        System.out.println("Longitude: " + latLong[1]);
    }
    

    Maybe is something new, but I think is much more convenient than the accepted answer.

提交回复
热议问题