주문을 요청할 수는 없지만 주문을 주문할 수는 있습니다. 이를 위해서는 RequestQueue을 구현해야합니다.
다음은 단일 스레드 실행을 사용하기 때문에 대기열에 추가 한 순서와 동일한 순서로 모든 요청을 실행하는 방법을 보여주는 샘플입니다.
// Copied from Volley.newRequestQueue(..); source code
File cacheDir = new File(context.getCacheDir(), "def_cahce_dir");
String userAgent = "volley/0";
try {
String packageName = context.getPackageName();
PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0);
userAgent = packageName + "/" + info.versionCode;
} catch (PackageManager.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));
}
}
int threadPoolSize = 1; // means only one request at a time
RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network, threadPoolSize);
queue.start();
우선 순위 사용에 대해 알고 있습니다. 그러나 우선 순위를 엉망으로 만들고 싶지 않지만 요청 대기열을 계속 뛰어 넘을 수있는 경우가 있습니다. 단편 A에서 장기 실행 요청이 몇 번 발생하는 경우 사용자가 단편 B로 이동하면 단편 B의 모든 요청을 먼저 처리하고 싶습니다. Priority.HIGH로 설정할 수 있지만 사용자가 C, D, E 등의 조각으로 이동하면 어떻게됩니까? 우선 순위가 없습니다. – StackOverflowed