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.