Sometimes I get the IOException when I try to get address through latitude and longitude via the geocoder class of android.
This occurs rarely and force closes my application.
private void locAdd(double latitude, double longitude) {
Geocoder geocoder = new Geocoder(ReportActivity.this,
Locale.getDefault());
try {
List<Address> addresses = geocoder.getFromLocation(latitude,
longitude, 1);
Log.e("Addresses", "-->" + addresses);
} catch (IOException e) {
e.printStackTrace();
}
}
This is the code I use to get location. Is there any issue with the code? How do I solve it?
Logcat
java.io.IOException: Unable to parse response from server
at android.location.Geocoder.getFromLocation(Geocoder.java:136)
at com.pstpl.crimeverify.CrimeReportActivity.locAdd(CrimeReportActivity.java:554)
at com.pstpl.crimeverify.CrimeReportActivity.access$10(CrimeReportActivity.java:549)