I am working on GPS system for android. I am able to find the latitude and longitude of my current position, but when I try to convert my latitude and longitude into Physical address my code doesn't work. I have tried several possibilities. I have posted my code here.
Any help is much appreciated. Thanks.
try {
List<Address> addresses = gc.getFromLocation(latitude, longitude, 1);
System.out.println(""+latitude);
StringBuilder sb = new StringBuilder();
if (addresses.size() > 0) {
Address address = addresses.get(0);
for (int i = 0; i < address.getMaxAddressLineIndex(); i++)
sb.append(address.getAddressLine(i)).append("\n");
sb.append(address.getLocality()).append("\n");
sb.append(address.getPostalCode()).append("\n");
sb.append(address.getCountryName());
}
addressString = sb.toString();
} catch (IOException e) {}
} else {
latLongString = "No location found";
}
myLocationText.setText("Your Current Position is:\n" +
latLongString + "\n" + addressString);
}
My problem is, I couldn't get any value in the List<Address> addresses = gc.getFromLocation(latitude, longitude, 1);
. It returns a empty list only.
Could anyone tell me what the problem is and how to sort it out...