user2685182
user2685182

Reputation: 141

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)

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:

Upvotes: 14

Views: 8405

Answers (6)

fobo66
fobo66

Reputation: 430

You can use Google Maps Services.

Geocoder in Android SDK is implemented by device vendors, and some of them don't want to bother with it.

UPD: Google Maps Services are not intended to use in Android, so you can use Mapbox Geocoder.

Upvotes: 0

Gautam
Gautam

Reputation: 1343

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

Upvotes: 3

Murtaza Ashraf
Murtaza Ashraf

Reputation: 308

I had the same error, add below permissions to resolve it.

<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> 
<uses-permission android:name="android.permission.INTERNET" />

Upvotes: 1

Bruno Pinto
Bruno Pinto

Reputation: 2013

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();
                        }
                }
        });        
}

Upvotes: 2

user1206553
user1206553

Reputation: 1

Try restart the "Network Location" service on Manege Apps.

Upvotes: 0

Baschi
Baschi

Reputation: 1128

You can add the Samsung Galaxy S II with Android 4.1.2 to your NOT WORKING list. This is an annoying bug and a work-around is to access the GMaps API in a direct manner. From my point of view it happens when the user kills all apps with the build-in task manager to free resources/memory.

Upvotes: 1

Related Questions