コード例 #1
0
    @Override
    protected String doInBackground(Void... params) {

      Geocoder geocoder = new Geocoder(WriteWeiboActivity.this, Locale.getDefault());

      List<Address> addresses = null;
      try {
        addresses = geocoder.getFromLocation(geoBean.getLat(), geoBean.getLon(), 1);
      } catch (IOException e) {
        cancel(true);
      }
      if (addresses != null && addresses.size() > 0) {
        Address address = addresses.get(0);

        StringBuilder builder = new StringBuilder();
        int size = address.getMaxAddressLineIndex();
        for (int i = 0; i < size; i++) {
          builder.append(address.getAddressLine(i));
        }
        return builder.toString();
      }

      return "";
    }