Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. //prints the location name
  2. public String getAddress(double lat, double lng, Context context) {
  3. Geocoder geocoder = new Geocoder(context, Locale.getDefault());
  4. try {
  5. List<Address> addresses = geocoder.getFromLocation(lat, lng, 1);
  6. Address obj = addresses.get(0);
  7. String add = obj.getAddressLine(0);
  8. add = add + "n" + obj.getCountryName();
  9. add = add + "n" + obj.getCountryCode();
  10. add = add + "n" + obj.getAdminArea();
  11. add = add + "n" + obj.getPostalCode();
  12. add = add + "n" + obj.getSubAdminArea();
  13. add = add + "n" + obj.getLocality();
  14. add = add + "n" + obj.getSubThoroughfare();
  15.  
  16. Log.v("IGA", "Address" + add);
  17.  
  18. return obj.getAddressLine(0);
  19.  
  20. } catch (IOException e) {
  21. // TODO Auto-generated catch block
  22. e.printStackTrace();
  23. //Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
  24. }
  25. return "";
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement