Getting street name from Address/Location object in Android

前端 未结 6 759
滥情空心
滥情空心 2021-01-31 11:34

I\'m trying to get the street name of my current location but I can\'t seem to get it.

I use this method to retrieve the Address:

public Address getAddre         


        
6条回答
  •  [愿得一人]
    2021-01-31 11:50

    Geocoder gcd = new Geocoder(this, Locale.getDefault());
    List
    addresses = gcd.getFromLocation(currentLatitude, currentLongitude,100); if (addresses.size() > 0 && addresses != null) { StringBuilder result = new StringBuilder(); myaddress.setText(addresses.get(0).getFeatureName()+"-"+addresses.get(0).getLocality()+"-"+addresses.get(0).getAdminArea()+"-"+addresses.get(0).getCountryName()); }
    • getfeaturename() return Streetname
    • getlocality() return city
    • getadminarea() return State

    That's All..!

提交回复
热议问题