Android - volley multiple requests

1.3k views Asked by At

I have 2 requests that I need to execute

onStart(...){
    callFirstWS();
    callSecondWS();
}

each function use a Singleton class with this format

SingletonClass.getInstance(<activity>).addToRequestQueue(<request>);

the singleton class

public final class InternetSingleton {
    private static InternetSingleton singleton;
    private RequestQueue requestQueue;
    private static Context context;

    private InternetSingleton(Context context) {
        InternetSingleton.context = context;
        requestQueue = getRequestQueue();
    }

    public static synchronized InternetSingleton getInstance(Context context) {
        if (singleton == null) {
            singleton = new InternetSingleton(context);
        }
        return singleton;
    }

    public RequestQueue getRequestQueue() {
        if (requestQueue == null) {
            requestQueue = Volley.newRequestQueue(context.getApplicationContext());
        }
        return requestQueue;
    }

    public void addToRequestQueue(Request request) {
        getRequestQueue().add(request);
    }
}

when I run my app, the first WS is called, the second not Any ideas?

1

There are 1 answers

0
AudioBubble On

I solved my problem.

in the response of 2st request I tried to set data from 1st response. sorry for my bad english