2

I am trying find lat & long from user given address, for that i am using following code,

GeoPoint pointForEnterAddr;


try {

    List<Address> address = coder.getFromLocationName(enterAddr, 1);

                    if (address == null)

                     pointForEnterAddr = null;

                    else {
                        Address location = address.get(0);
                        System.out.println("Lat in button click :"
                                + location.getLatitude());
                        System.out.println("Long in button click :"
                                + location.getLongitude());


pointForEnterAddr = new GeoPoint((int) (location.getLatitude() * 1E6),
                    (int) (location.getLongitude() * 1E6));


}
 catch (Exception ex) {
                    System.out.println("Error here :" + ex);
                }

But everytime it coming to catch part & shows exception, java.io.IOException: Service not Available

How can i solve it and get proper output? Plz tell me.

Thank you

George
  • 1,327
  • 11
  • 25
Jyosna
  • 4,436
  • 13
  • 60
  • 93

2 Answers2

1

I found this for your questions, I think it is the bug of emulator. Look at this answer

Android; Geocoder, why do I get "the service is not available"?

Community
  • 1
  • 1
George
  • 1,327
  • 11
  • 25
0

Just to mention an alternative, you can use the Google Maps' REST based reverse geocoder. You can probably use this as a fallback. As you would be using Google Maps in your app too, you should be good with the API rules.

Abhinav
  • 38,516
  • 9
  • 41
  • 49
  • It's not entirely correct. If you don't use the given methods it's the same as you call the API from some random server, meaning you are limited by the number of daily calls. – thedp Aug 03 '14 at 19:17