Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GeoCoder Service not Available

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.

QUESTION

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)

  • 4.0.3 Samsung Galaxy Note (GT-N7000)
  • 4.0.4 Samsung Tablet GT-P7100
  • 4.1.2 nexus S
  • 4.1.2 Samsung Galaxy S III (GT-I9300)

WORKING (did restart LocationService)

  • 2.3.5 HTC Wildfired S
  • 4.0.3 Acer A500
  • 4.1.1 Samsung Galaxy Note II (GT-7100)
  • 4.1.2 Samsung Galaxy S II (GT-I9105P)
  • 4.2.2 Samsung Tablet GT-P7500
  • 4.2.2 Nexus 7
  • 4.3 Galaxy Nexus

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:

  • Android bugTracker issue 38009
  • StackOverFlow 7109240
like image 773
user2685182 Avatar asked Aug 15 '13 08:08

user2685182


2 Answers

Restart device check again(i have face same issue.)

like image 141
Gautam Avatar answered Nov 12 '22 14:11

Gautam


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();
                        }
                }
        });        
}
like image 2
Bruno Pinto Avatar answered Nov 12 '22 15:11

Bruno Pinto