guo guo - 1 year ago 81
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?

Answer Source

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