So I tried to convert a text address into coordinates using geocoder.getFromLocationName() in kotlin
import android.location.Geocoder
val geocoder = Geocoder(context, Locale.getDefault())
try {
val result = geocoder.getFromLocationName(club.location, 1) // it gets hung here before throw!!
Log.d(LOG_TAG, "${club.location} translates into cordinates : ${result[0].latitude}, ${result[0].longitude}")
}
catch (ex : Exception){
Log.d(LOG_TAG, "${ex.message}")
}
but it always catches the exception saying
Caused by: java.io.IOException: DEADLINE_EXCEEDED: ClientCall started after deadline exceeded: -15.077367176s from now
at android.location.Geocoder$SynchronousGeocoder.getResults(Geocoder.java:388)
at android.location.Geocoder.getFromLocationName(Geocoder.java:277)
at android.location.Geocoder.getFromLocationName(Geocoder.java:202)
Is the Geocoder in android not working ? find it hard to believe .. or did I miss anything ?
I tried to look up online but not found helpful responses