當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。