based on this tutorial: http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/. I can now get latitude and longtitude based on location. Now I', trying to get the exact address with Geocoder: (Main is the class code above belongs to)
GPSTracker GPS = new GPSTracker(Main.this);
double latitude = GPS.getLatitude();
double longitude = GPS.getLongitude();
Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(Main.this, Locale.getDefault());
addresses = geocoder.getFromLocation(latitude, longitude, 1);
String address = addresses.get(0).getAddressLine(0);
LogCat says:
07-06 11:29:41.911: W/System.err(1670): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
I wonder what am I doing wrong?