GeoCoder Service not Available
I'm using the GeoCoder
to get an AddressLocation
.
Unfortunately the method fires an IOException saying: "Service not Available"
.
This StackOverFlow thread explains what is going on because I tested it thoroughly (user permissions, build versions, restarts, GeoCoding API limits, etc.).
The Google Play-Services
(or LocationService
) that you can find in: Android Settings -> (Manage) Applications --> Running Process, has crashed or stopped. It restarts itself but forgets to bind the GeoCoderService to the NetworkLocator.
The "Solution" to this bug is to restart the Android phone, because on reboot the GeoCoderService is binded to the NetworkLocater. Of course I do not find this a solution.
My question is, how does the LocationService crash or get stopped in the first place?
What I did is force-stop the Google Play-Service by hand and some devices restarted the LocationService but some didn't.
NOT WORKING (did not restart LocationService)
WORKING (did restart LocationService)
Does anybody know what the reason is that the Google Play-service (LocationService) crashes or get's stopped after running a while?
I already escalated this issue to the b.Android.com and personally contacted Android developers.
I've seen that my issue has been discussed in other threads but did not pull any conclusion:
Restart device check again(i have face same issue.)
Some devices do not have suport for Geocoder, so what you need to do is create your own geocoder.
Basicaly you need create a async task to request google for the address and treat the json response.
Using aquery, i do something like this:
public void asyncJson(String address){
address = address.replace(" ", "+");
String url = "http://maps.googleapis.com/maps/api/geocode/json?address="+ address +"&sensor=true";
aq.ajax(url, JSONObject.class, new AjaxCallback<JSONObject>() {
@Override
public void callback(String url, JSONObject json, AjaxStatus status) {
if(json != null){
//here you work with the response json
JSONArray results = json.getJSONArray("results");
Toast.makeText(context, results.getJSONObject(1).getString("formatted_address"));
}else{
//ajax error, show error code
Toast.makeText(aq.getContext(), "Error:" + status.getCode(), Toast.LENGTH_LONG).show();
}
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With