sto recuperando il contenuto di un indirizzo web non valido con tiro al volo, vale a dire: http://www.gigd32fdsu.com
Questo è il mio codice di prova:codice di stato HTTP GET per le richieste di successo con Volley
// Instantiate the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(this);
final String url = "http://www.gigd32fdsu.com";
// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener() {
@Override
public void onResponse(Object response) {
// Display the first 500 characters of the response string.
mTextView.setText("Response is: " + response.toString().substring(0, 500));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mTextView.setText("That didn't work! " + error.networkResponse.statusCode);
}
});
// Add the request to the RequestQueue.
queue.add(stringRequest);
Quando eseguo questo codice ricevo il callback onResponse (String) con una pagina di errore dal mio ISP. Come posso leggere il codice di stato HTTP per rilevare che la visualizzazione web non è corretta?
Grazie
consultare questo http://stackoverflow.com/questions/22948006/http-status-code-in-android-volley-when-error-networkresponse-is-null –