Prasanna Aarthi
Prasanna Aarthi

Reputation: 3453

Google glass- unable to get address from location

I am trying to get address of a location by passing latitude and longitude.But the address is always null.

Here is my code..

@Override
        public void onLocationChanged(Location location) {
        // Called when a new location is found by the network location provider.
        if (location != null){
        Geocoder geocoder = new Geocoder(Start_service.this.getBaseContext(), Locale.getDefault());
        // lat,lng, your current location

        try {
            lati= location.getLatitude();
            longi=location.getLongitude();
            speed=location.getSpeed();
            addresses =geocoder.getFromLocation(location.getLatitude(),location.getLongitude(), 1);
        System.out.println("Address is"+ addresses);
        }
        catch (IOException e) {
        System.out.println(e);
        e.printStackTrace();
        }

Upvotes: 0

Views: 78

Answers (1)

Alain
Alain

Reputation: 6034

From the Android's Geocoder doc:

The Geocoder class requires a backend service that is not included in the core android framework. The Geocoder query methods will return an empty list if there no backend service in the platform. Use the isPresent() method to determine whether a Geocoder implementation exists.

If you would like to have it supported on Glass, feel free to file a feature request on our issues tracker.

You could also use alternative API such as the Google Geocoding API.

Upvotes: 1

Related Questions