I have my own Android application using the volley framework to receive data from the end of the server PHPscript.
It worked well in most cases, but I have a 20% failure.
The error says:
com.android.volley.NoConnection, java.io.InterruptedIOException.
I debugged what I found statuscode = 0, which was obviously wrong.
I have no idea what could be causing? Since it works the most time, there should be no obvious error code.
FYI, those PHP scripts on the server work fine for my iOS application.
Please let me write my code here:
retryConnBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
txtOut.append("\n");
txtOut.append("Button with Retry Click");
Log.d("Click", "Button Click");
final String url = "https://www.myserver.com/api/getBalanceInfoTest?token=7ff3317a4f3dc07d0c297a7d16d2049c&t=" + System.currentTimeMillis();
JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
txtOut.append("\n");
txtOut.append("Result with Retry:");
txtOut.append(response.toString());
Log.d("Response", response.toString());
VolleyLog.e("Response:", response.toString());
}
},
new Response.ErrorListener(){
@Override
public void onErrorResponse(VolleyError error) {
txtOut.append("\n");
txtOut.append("Error with Retry:");
txtOut.append(error.toString());
Log.d("Error.Response", error.toString());
VolleyLog.e("Error:", error.getMessage());
}
});
getRequest.setRetryPolicy(new DefaultRetryPolicy(5000, 5, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
queue.add(getRequest);
queue.start();
}
});
}
PHP script:
{"hsaBalance":"1000.00"}, Json_encode() PHP.