Как я могу сделать этот код короче или чище?

Попробуйте использовать код ниже с помощью геокодера:

  Geocoder gcd = new Geocoder(MainActivity.this, Locale.getDefault());
  List<Address> geoAddresses = geoAddresses = gcd.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
  if (geoAddresses.size() > 0) {
      String mUserLocation = "";
      for (int i = 0; i < 4; i++) { //Since it return only four value we declare this as static.
           mUserLocation = mUserLocation + geoAddresses.get(0).getAddressLine(i).replace(",", "") + ", ";
        } 
    }
-11
задан Rufus L 15 June 2019 в 00:43
поделиться