guo guo - 6 months ago 59
Android Question

android volley OnTimeout mehod

How to handle the timeout event in volley, e.g., give a hint for user? I cannot find any useful stuff after googling.

Should I write the logic in

when creating a request?


There is an Exception called TimeoutError defined in Volley , You can make use of that. adding an example below

Response.ErrorListener errorListener = new Response.ErrorListener() {
    public void onErrorResponse(VolleyError volleyError) {
        if (volleyError.networkResponse == null) {
            if (volleyError.getClass().equals(TimeoutError.class)) {
                // Show timeout error message
                        "Oops. Timeout error!",

Also please see this link