In my android app i am trying to get the address from lat
lng
using the Geocoder using getFromLocation
method and the GeocodeListener
but sometimes the app is getting crashed
Crash Log
Caused by java.io.IOException: egma: DEADLINE_EXCEEDED: Deadline CallOptions will be exceeded in 4.959774531s.
at android.location.Geocoder$GeocodeListener.getResults(Geocoder.java:246)
at android.location.Geocoder.getFromLocation(Geocoder.java:134)
Code
geocoder.getFromLocation(
latLng.latitude,
latLng.longitude,
1,
object : Geocoder.GeocodeListener {
override fun onGeocode(addresses: MutableList<Address>) {
val addressLine = addresses.first().getAddressLine(0)
onAddressResult(addressLine, null) // callback
}
override fun onError(errorMessage: String?) {
super.onError(errorMessage)
onAddressResult(null, errorMessage)
}
},
)
What is the reason for the crash. how can i avoid it?