Good, someone knows because of a month here when using getFromLocation with Geocoder, it gives an IOException error: GRPC failed.
The code is as follows:
public String getCountryCode(Context context) {
Geocoder geocoder = new Geocoder(context, Locale.getDefault());
List<Address> addresses;
try {
//Address adr=(Address)geocoder.getFromLocation(latitude, longitude, 1);
addresses = geocoder.getFromLocation(latitude, longitude, 1);
//return adr.getCountryCode();
if (addresses != null && !addresses.isEmpty()) {
return addresses.get(0).getCountryCode();
}
//Address result;
} catch (IOException e) {
//do something
e.printStackTrace();
//return null;
}
return null;
}
Thanks in advance.