Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void getAddressFromLocation(final double latitude, final double longitude,
- final Context context, final Handler handler) {
- Thread thread = new Thread() {
- @Override
- public void run() {
- Geocoder geocoder = new Geocoder(context, Locale.getDefault());
- String result = null;
- // String tudo[] = new String[0];
- try {
- List<Address> addressList = geocoder.getFromLocation(
- latitude, longitude, 1);
- if (addressList != null && addressList.size() > 0) {
- Address address = addressList.get(0);
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
- sb.append(address.getAddressLine(i)).append("n");
- // tudo[i] = address.getAddressLine(i).concat("n");
- }
- sb.append(address.getAdminArea()).append("n");
- sb.append(address.getLocality()).append("n");
- sb.append(address.getPostalCode()).append("n");
- result = sb.toString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement