1

In my app I want to decode raw address into coordinates. I do it like that:

AsyncHttpClient client = new AsyncHttpClient();
RequestParams params = new RequestParams();
try {
    params.add("geocode", URLEncoder.encode(charSequence.toString(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
}

client.post(getApplicationContext(), "https://geocode-maps.yandex.ru/1.x/", params, new AsyncHttpResponseHandler() {
      @Override
      public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
          Log.d("Yandex Geocode", "Success! Answer = " + new String(responseBody));
      }

      @Override
      public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
          Log.d("Yandex Geocode", "Failure :( Error = " + error.toString());
      }
});

However, this request can't reach server.

failed to connect to geocode-maps.yandex.ru/213.180.204.122 (port 443) after 10000ms: isConnected failed: ECONNREFUSED (Connection refused)

Any suggestions why it't not working?

EDIT

It not working because yandex provides this api only for webapps and sites. Found an ugly workaround for this. I'm loading a page in webview with this request url and getting raw text from response, from webview.

TrueCH
  • 501
  • 1
  • 6
  • 18

1 Answers1

0

You can try with Android Geocoder. It is android native API.

A class for handling geocoding and reverse geocoding.

Thirumalvalavan
  • 2,660
  • 1
  • 30
  • 32
  • the problem is that Android Geocoder and Google geocoder works bad with russian addresses. Yandex maps api is the best for russian addresses – TrueCH Mar 03 '17 at 04:12