해결android.volley.NoConnection error, java.io.InterruptedIOException

request를 사용했습니다.start(), 그래서 생긴 문제입니다.
public static void RequstGet_JSONObject() {
        request.cancelAll(tag);
        jsonObjectRequest.setTag(tag);
        request.add(jsonObjectRequest);
        request.start();
}

volley가 RequestQueue를 초기화할 때 start 방법을 호출했기 때문입니다.
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;
}

해결 방법:


요청을 삭제합니다.start (), 하면 됩니다.
public static void RequstGet_JSONObject() {
        request.cancelAll(tag);
        jsonObjectRequest.setTag(tag);
        request.add(jsonObjectRequest);
}

좋은 웹페이지 즐겨찾기