user4938025
user4938025

Reputation:

Android - volley multiple requests

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?

Upvotes: 1

Views: 1388

Answers (1)

user4938025
user4938025

Reputation:

I solved my problem.

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

Upvotes: 1

Related Questions