Kiran Kumar S
Kiran Kumar S

Reputation: 11

How to make a synchronous volley StringRequest?

How to make Volley StringRequest should wait for the one response to complete and after completing the first response it should start another request.

Upvotes: 0

Views: 62

Answers (2)

M.Ahmed
M.Ahmed

Reputation: 255

Inside onResponse of your StringRquest make the second request you want.

StringRequest stringRequest = new StringRequest(Request.Method.POST, recieveMessageUrl, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                //create second request here
                //and add it to queue 
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
               
            }
        });

Note: you will have to make sure that your response is valid otherwise the onErrorResponse will be called.

Upvotes: 0

axar
axar

Reputation: 539

you have to do if your first response successfully then call these second method your answers is into your question

Upvotes: 1

Related Questions