I'm working on a map gallery. I need location information of photos. While working on this, I encountered a wired situation. I used intent to call ACTION_OPEN_DOCUMENT and picked an image. Then used its MediaStore.Images.Media.EXTERNAL_CONTENT_URI to generate an inputstream. Finaly I passed the inputstream in to ExifInterface() and get its location. I works flawlessly.
val fileInputStream = pickedImageUri?.let { it1 -> getInputStreamFromUri(context, it1) }
Timber.e("pickedImageUri:$pickedImageUri")
Timber.e("fileInputStream:$fileInputStream")
val imageExif = fileInputStream?.let { it1 -> ExifInterface(it1) }
Timber.e("imageExif:$imageExif")
val imageLocationRaw = LatLng(
imageExif?.latLong?.get(0) ?: 0.0,
imageExif?.latLong?.get(1) ?: 0.0
)
if (imageExif != null) {
Timber.e("latlong:${imageExif.latLong}")
}
Timber.e("imageLocationRaw:$imageLocationRaw")
But I thought photo picker is more convinient for selecting photos. So I moved to photo picker. I used the same method to extract location. However, error occurs at imageExif?.latLong?. It's always null. Warning from the Logcat is 'Latitude/longitude values are not parsable. latValue=0/1,0/1,0/1, latRef=, lngValue=0/1,0/1,0/1, lngRef='
why? how can i get locaiton correctly?