本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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();
}
示例5: initConnectionRequest
import com.android.volley.RequestQueue; //导入方法依赖的package包/类
private void initConnectionRequest(Cache cache, Network network) {
mRequestQueue = new RequestQueue(cache, network);
mRequestQueue.start();
}
示例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;
}
示例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();
}
示例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);
}
}