Code example for NetworkInfo

Methods: getReason, getSubtype, isConnected, isFailover

0
        } 
 
        // Reset network if type changed. 
        if (mobileInfo != null) {
            if (currentNetworkSubType != mobileInfo.getSubtype()) {
                currentNetworkSubType = mobileInfo.getSubtype();
                resetNetwork(); 
            } 
 
            // On 2.2 this receiver fires when we register for it, so we get the current state, not a transition, so 
            // typically in this case isFailover() is going to be true from the last failover, so we don't reset the 
            // network in that case. We also have the default HttpAccess instance created early on 
            // so that this initial receive can be processed before we try and make any calls. 
            if (mobileInfo.isFailover()) {
                if (!mobileInfo.isConnected()) {
                    setHasNetwork(false, "No active data connection"); 
                    return; 
                } 
            } 
            if (mobileInfo.isConnected()) {
                setHasNetwork(true, null); 
                return; 
            } 
            setHasNetwork(false, mobileInfo.getReason() == null ? wifiInfo.getReason() : mobileInfo.getReason());
        } 
    } 
 
    /** 
     * Shut down existing connections and create a new http client. 
     */