FileDocCategorySizeDatePackage
Volley.javaAPI DocAndroid 5.1 API2896Thu Mar 12 22:22:56 GMT 2015com.android.volley.toolbox

Volley

public class Volley extends Object

Fields Summary
private static final String
DEFAULT_CACHE_DIR
Default on-disk cache directory.
Constructors Summary
Methods Summary
public static com.android.volley.RequestQueuenewRequestQueue(android.content.Context context, HttpStack stack)
Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it.

param
context A {@link Context} to use for creating the cache dir.
param
stack An {@link HttpStack} to use for the network, or null for default.
return
A started {@link RequestQueue} instance.


                                                       
           
        File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR);

        String userAgent = "volley/0";
        try {
            String packageName = context.getPackageName();
            PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0);
            userAgent = packageName + "/" + info.versionCode;
        } catch (NameNotFoundException e) {
        }

        if (stack == null) {
            if (Build.VERSION.SDK_INT >= 9) {
                stack = new HurlStack();
            } else {
                // Prior to Gingerbread, HttpUrlConnection was unreliable.
                // See: http://android-developers.blogspot.com/2011/09/androids-http-clients.html
                stack = new HttpClientStack(AndroidHttpClient.newInstance(userAgent));
            }
        }

        Network network = new BasicNetwork(stack);

        RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network);
        queue.start();

        return queue;
    
public static com.android.volley.RequestQueuenewRequestQueue(android.content.Context context)
Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it.

param
context A {@link Context} to use for creating the cache dir.
return
A started {@link RequestQueue} instance.

        return newRequestQueue(context, null);