我正在尝试从图库中获取图像的GPS LatLng位置,我正在使用以下代码:
设置从图库中挑选的意图:
val intent = Intent(Intent.ACTION_PICK)
intent.type = "image/*"
startActivityForResult(intent, 2)
检索结果:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if(requestCode == 2 && resultCode == RESULT_OK) {
val exif = ExifInterface(data?.data!!.encodedPath)
var photoCurr:FloatArray = floatArrayOf(2F)
if(exif.getLatLong(photoCurr)){
var latlng = LatLng(photoCurr.get(0) as Double, photoCurr.get(1) as Double)
}
}
但是我收到以下错误消息:
Caused by: java.io.FileNotFoundException: /-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F29/ORIGINAL/NONE/863798572: open failed: ENOENT (No such file or directory)