I am using these two threads:
How to find postcode by latitude and logitude for UK
Get current location using GPS in Android
and have successfully managed to implement a GPStracker, however, when I try to recieve the postcode using the first thread it does not give me any post:
I have this as global variable:
public String receivePostCode = "";
and then in onCreate I have this:
Geocoder geoCoder = new Geocoder(getActivity().getApplicationContext(), Locale.getDefault());
List<Address> address = null;
if (geoCoder != null) {
try {
address = geoCoder.getFromLocation(latitude, longitude, 1);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (address.size() > 0) {
receivePostCode = address.get(0).getPostalCode();
}
}
These are the global variables that I am using to recieve lat and long from my GPStracker class:
GPSTracker gps = new GPSTracker(getActivity());
double latitude = gps.getLatitude();
double longitude = gps.getLongitude();
Any help would be nice.