当前位置: 首页>>代码示例>>Java>>正文


Java RequestQueue.start方法代码示例

本文整理汇总了Java中com.android.volley.RequestQueue.start方法的典型用法代码示例。如果您正苦于以下问题:Java RequestQueue.start方法的具体用法?Java RequestQueue.start怎么用?Java RequestQueue.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.volley.RequestQueue的用法示例。


在下文中一共展示了RequestQueue.start方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newVolleyRequestQueueForTest

import com.android.volley.RequestQueue; //导入方法依赖的package包/类
private RequestQueue newVolleyRequestQueueForTest(final Context context) {
    File cacheDir = new File(context.getCacheDir(), "cache/volley");
    Network network = new BasicNetwork(new HurlStack());
    ResponseDelivery responseDelivery = new ExecutorDelivery(Executors.newSingleThreadExecutor());
    RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network, 4, responseDelivery);
    queue.start();

    return queue;
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:10,代码来源:BaseTest.java

示例2: newRequestQueue

import com.android.volley.RequestQueue; //导入方法依赖的package包/类
/**
 * 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.
 */
public static RequestQueue newRequestQueue(Context context, HttpStack stack) {
    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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:Volley.java

示例3: onCreate

import com.android.volley.RequestQueue; //导入方法依赖的package包/类
@Override
public boolean onCreate() {
  Context context = getContext();
  if (context == null) {
    return false;
  }
  if (!AppPerformanceConfig.enabled) {
    return false; // Return when instrumentation is disabled
  }

  RequestQueue queue = new RequestQueue(new NoCache(), new BasicNetwork(new HurlStack()));
  queue.start();

  BatteryInfoStore batteryInfoStore = new BatteryInfoStore(context);

  String subscriptionKey = Util.getSubscriptionKey(context);

  String configUrlPrefix = Util
      .getMeta(context, "com.rakuten.tech.mobile.perf.ConfigurationUrlPrefix");
  String relayAppId = Util.getRelayAppId(context);
  ConfigStore configStore = new ConfigStore(context, queue, relayAppId, subscriptionKey,
      configUrlPrefix);

  // Read last config from cache
  Config config = createConfig(context, configStore.getObservable().getCachedValue(), relayAppId);
  if (config != null) {
    String locationUrlPrefix = Util
        .getMeta(context, "com.rakuten.tech.mobile.perf.LocationUrlPrefix");
    LocationStore locationStore = new LocationStore(context, queue, subscriptionKey,
        locationUrlPrefix);
    // Initialise Tracking Manager
    TrackingManager.initialize(context, config, locationStore.getObservable(),
        batteryInfoStore.getObservable());
    Metric.start("_launch");
  }
  return false;
}
 
开发者ID:rakutentech,项目名称:android-perftracking,代码行数:38,代码来源:RuntimeContentProvider.java

示例4: RemoteDataSource

import com.android.volley.RequestQueue; //导入方法依赖的package包/类
public RemoteDataSource(String url) {
        mUrl = url;
        // TODO: context should be Application context + this should be a singleton
//        mRequestQueue = Volley.newRequestQueue(context.getApplicationContext());
        mRequestQueue = new RequestQueue(new NoCache(), new BasicNetwork(new HurlStack()));
        //TODO: disable volley cache
        mRequestQueue.start();
    }
 
开发者ID:googlecodelabs,项目名称:security-config,代码行数:9,代码来源:RemoteDataSource.java

示例5: initConnectionRequest

import com.android.volley.RequestQueue; //导入方法依赖的package包/类
private void initConnectionRequest(Cache cache, Network network) {
  mRequestQueue = new RequestQueue(cache, network);
  mRequestQueue.start();
}
 
开发者ID:wondenge,项目名称:payments-Android-SDK,代码行数:5,代码来源:ApiInvoker.java

示例6: resolve

import com.android.volley.RequestQueue; //导入方法依赖的package包/类
public static int resolve(Context context, final int[] image_data, final TextView textViewDigit, final TextView textViewMatch) {

        RequestQueue queue = Volley.newRequestQueue(context);
        String url = "http://" + serverIp + ":" + serverPort;

        // Request a string response from the provided URL.
        StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        // Display the first 500 characters of the response string.
                        String[] responseSplit = response.split(",");

                        textViewDigit.setText(responseSplit[0]);
                        textViewMatch.setText(responseSplit[1]);
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Log.e(TAG, "Request error", error);

                        textViewDigit.setText("X");
                        textViewMatch.setText("Request error");
                    }
                }
        ) {
            @Override
            protected Map<String, String> getParams()
            {
                Map<String, String>  params = new HashMap<String, String>();

                StringBuilder imageDataStr = new StringBuilder();

                for (int i = 0; i < image_data.length; i++) {
                    imageDataStr.append(image_data[i]);
                }

                Log.d(TAG, "imageDataStr.toString(): " + imageDataStr.toString());

                params.put("image", imageDataStr.toString());

                return params;
            }
        };

        // Add the request to the RequestQueue.
        queue.add(stringRequest);

        queue.start();

        return 0;
    }
 
开发者ID:dhiogoboza,项目名称:iahandwritten,代码行数:53,代码来源:DigitResolver.java

示例7: RemoteDataSource

import com.android.volley.RequestQueue; //导入方法依赖的package包/类
public RemoteDataSource(String url) {
    mUrl = url;
    mRequestQueue = new RequestQueue(new NoCache(), new BasicNetwork(new HurlStack()));
    mRequestQueue.start();
}
 
开发者ID:googlecodelabs,项目名称:android-network-security-config,代码行数:6,代码来源:RemoteDataSource.java

示例8: delete

import com.android.volley.RequestQueue; //导入方法依赖的package包/类
public void delete() {

        final long then = System.nanoTime();

        String url = null;

        try {
            url = DELETE_URL + URLEncoder.encode(profileId, Constants.ENCODING_UTF8);
        } catch (final UnsupportedEncodingException e) {
            if (DEBUG) {
                MyLog.w(CLS_NAME, "delete: UnsupportedEncodingException");
                e.printStackTrace();
            }
        }

        final RequestQueue queue = Volley.newRequestQueue(mContext);
        queue.start();

        final StringRequest stringRequest = new StringRequest(Request.Method.DELETE, url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(final String response) {
                        if (DEBUG) {
                            MyLog.i(CLS_NAME, "onResponse: success");
                        }
                        queue.stop();
                    }
                },

                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(final VolleyError error) {
                        if (DEBUG) {
                            MyLog.w(CLS_NAME, "onErrorResponse: " + error.toString());
                            DeleteIDProfile.this.verboseError(error);
                        }
                        queue.stop();
                    }
                }) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                final Map<String, String> params = new HashMap<>();
                params.put(CHARSET, Constants.ENCODING_UTF8);
                params.put(OCP_SUBSCRIPTION_KEY_HEADER, apiKey);
                return params;
            }
        };

        stringRequest.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        queue.add(stringRequest);

        if (DEBUG) {
            MyLog.getElapsed(CLS_NAME, then);
        }

    }
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:59,代码来源:DeleteIDProfile.java


注:本文中的com.android.volley.RequestQueue.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。