Skip to content

Instantly share code, notes, and snippets.

@SPurno
Created October 31, 2018 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SPurno/b790e293e1eaa8e8fbefc62964884a07 to your computer and use it in GitHub Desktop.
Save SPurno/b790e293e1eaa8e8fbefc62964884a07 to your computer and use it in GitHub Desktop.
Android Volley Help
package com.syntech.spurno.post;
import android.content.Context;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
public class RequestQueueSingleton {
private static RequestQueueSingleton requestQueueSingleton;
private RequestQueue requestQueue;
private static Context context;
private RequestQueueSingleton(Context ctx){
context = ctx;
requestQueue = getRequestQueue();
}
public static synchronized RequestQueueSingleton getInstance(Context context){
if (requestQueueSingleton == null){
requestQueueSingleton = new RequestQueueSingleton(context);
}
return requestQueueSingleton;
}
public RequestQueue getRequestQueue() {
if (requestQueue == null){
requestQueue = Volley.newRequestQueue(context.getApplicationContext());
}
return requestQueue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment