disable Connection Reuse If Necessary for HTTP connection - Android Network

Android examples for Network:HTTP

Description

disable Connection Reuse If Necessary for HTTP connection

Demo Code


//package com.java2s;
import android.os.Build;

public class Main {
    private static void disableConnectionReuseIfNecessary() {
        // HTTP connection reuse which was buggy pre-froyo
        if (hasHttpConnectionBug()) {
            System.setProperty("http.keepAlive", "false");
        }//from w  w  w.j  a v  a 2 s  .c o m
    }

    private static boolean hasHttpConnectionBug() {
        return Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO;
    }
}

Related Tutorials