I am using a large asynchronous http library from loopj, but I ran into a small error.
If the user does not have an Internet connection or is not connected, the application simply will not return anything. This part is expected, but it also does not run the onFailure method.
In addition, the code that I used when connecting to the Internet works, so there are no problems on the server.
Here is some code that is split to a minimum. It also doesn't work (I experienced it too)
String url = getString(R.string.baseurl) + "/appconnect.php"; client.getHttpClient().getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true); client.get(url, null, new JsonHttpResponseHandler() { @Override public void onSuccess(JSONArray response) { Toast.makeText(getApplicationContext(), "Success", Toast.LENGTH_SHORT).show(); } @Override public void onFailure(Throwable e, JSONArray errorResponse) { Toast.makeText(getApplicationContext(), "Failure", Toast.LENGTH_SHORT).show(); } });
Thanks Ashley
Ashley staggs
source share