0

My problem is that I have an Activity that when you push a button a Timer start to count, and in the same moment gets the coordinates and save it into a variable. Then when you push another time the button the timer stop and get a new coordinates and save it in an other variables.

Then I'm doing inverse geocoding with this code:

private void tradueixpos() {
    Geocoder geoCoder = new Geocoder(this, Locale.getDefault());
    try {
        Log.v("e", String.valueOf(latituteField));
        Log.v("e", String.valueOf(longitudeField));
        List<Address> Locat = geoCoder.getFromLocation(latituteField, longitudeField, 1);
        if (!Locat.isEmpty()) {
            Address address = Locat.get(0);
            result = address.getAddressLine(0) + ", " + address.getLocality();
            //number = address.getSubThoroughfare();
            //streetName = address.getThoroughfare();
            //Log.v("e", number+", "+streetName);
        }
        else {
            Log.v("error", "no trobat");
        }       
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

So after that it pass the Initial address and the final address to another activity.

My problem is that it return null or sometime it didn't work, an all the time is getting some errors. The geocoding is not working I think.

(I'm working with api 15)

I put the permissions, so is anyone able to help me to do this??

thanks

General Grievance
  • 4,555
  • 31
  • 31
  • 45
sticko
  • 21
  • 1
  • 4
  • Plz check this answer describing how-to implement in details http://stackoverflow.com/questions/6433922/android-does-addressfrom-geocode-have-fixed-format/6480558#6480558 – Yilmaz Guleryuz Feb 04 '12 at 14:26

2 Answers2

0

Look at http://developer.android.com/reference/android/location/Geocoder.html. It says :

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.

zambotn
  • 735
  • 1
  • 7
  • 20
  • I finally solve the problem, but now the coordenats are not good, I mean it entry in the console "geo fix 43.231 1.899" that are the coordenates near my home, but the program say that the coordantes are from Somalie.... It's that normal? – sticko Feb 06 '12 at 16:31
  • 1
    you have to invert latitude and longitude! =) – zambotn Feb 06 '12 at 17:49
0

If you are testing in an emulator then, in later versions of the emulator the service doesn't work. I know for instance that it's broken in API 9. I wouldn't be surprised if the same is true for API 15. I know that an API 7 emulator does work, so you might like to try the same code in API 7. On real devices it still appears to work OK. (My Gingerbread phone works OK)

NickT
  • 23,844
  • 11
  • 78
  • 121