Example usage for android.net ConnectivityManager TYPE_MOBILE_SUPL

List of usage examples for android.net ConnectivityManager TYPE_MOBILE_SUPL

Introduction

In this page you can find the example usage for android.net ConnectivityManager TYPE_MOBILE_SUPL.

Prototype

int TYPE_MOBILE_SUPL

To view the source code for android.net ConnectivityManager TYPE_MOBILE_SUPL.

Click Source Link

Document

A SUPL-specific Mobile data connection.

Usage

From source file:com.amazonaws.mobileconnectors.pinpoint.internal.core.system.AndroidConnectivity.java

private void determineAvailability() {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    inAirplaneMode = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
            0) != 0;//from   w  ww .ja  v a  2 s  . c  om
    log.info("Airplane mode: " + inAirplaneMode);
    final NetworkInfo networkInfo = cm != null ? cm.getActiveNetworkInfo() : null;
    int networkType = 0;
    // default state
    hasWifi = false;
    // when we have connectivity manager, we assume we have some sort of
    // connectivity
    hasMobile = cm != null;
    // can we obtain network info?
    if (networkInfo != null) {
        if (networkInfo.isConnectedOrConnecting()) {
            networkType = networkInfo.getType();

            hasWifi = networkType == ConnectivityManager.TYPE_WIFI
                    || networkType == ConnectivityManager.TYPE_WIMAX;
            hasMobile = networkType == ConnectivityManager.TYPE_MOBILE
                    || networkType == ConnectivityManager.TYPE_MOBILE_DUN
                    || networkType == ConnectivityManager.TYPE_MOBILE_HIPRI
                    || networkType == ConnectivityManager.TYPE_MOBILE_MMS
                    || networkType == ConnectivityManager.TYPE_MOBILE_SUPL;
        } else {
            // if neither connected or connecting then hasMobile defaults
            // need to be changed to false
            hasMobile = false;
        }
    }
    log.info(String.format("Device Connectivity (%s)",
            hasWifi ? "On Wifi" : (hasMobile ? "On Mobile" : "No network connectivity")));
}

From source file:dev.ukanth.ufirewall.InterfaceTracker.java

private static InterfaceDetails getInterfaceDetails(Context context) {
    InterfaceDetails ret = new InterfaceDetails();

    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = cm.getActiveNetworkInfo();

    if (info == null || info.isConnected() == false) {
        return ret;
    }/*from   w  ww.  ja v a  2s.co m*/

    switch (info.getType()) {
    case ConnectivityManager.TYPE_MOBILE:
    case ConnectivityManager.TYPE_MOBILE_DUN:
    case ConnectivityManager.TYPE_MOBILE_HIPRI:
    case ConnectivityManager.TYPE_MOBILE_MMS:
    case ConnectivityManager.TYPE_MOBILE_SUPL:
    case ConnectivityManager.TYPE_WIMAX:
        ret.isRoaming = info.isRoaming();
        ret.netType = ConnectivityManager.TYPE_MOBILE;
        ret.netEnabled = true;
        break;
    case ConnectivityManager.TYPE_WIFI:
    case ConnectivityManager.TYPE_BLUETOOTH:
    case ConnectivityManager.TYPE_ETHERNET:
        ret.netType = ConnectivityManager.TYPE_WIFI;
        ret.netEnabled = true;
        break;
    }
    getTetherStatus(context, ret);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
        OldInterfaceScanner.populateLanMasks(context, ITFS_WIFI, ret);
    } else {
        NewInterfaceScanner.populateLanMasks(context, ITFS_WIFI, ret);
    }

    return ret;
}

From source file:at.alladin.rmbt.android.util.InformationCollector.java

/** Returns the network that the phone is on (e.g. Wifi, Edge, GPRS, etc). */
public int getNetwork() {
    int result = TelephonyManager.NETWORK_TYPE_UNKNOWN;

    if (connManager != null) {
        final NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo();
        if (activeNetworkInfo != null) {
            final int type = activeNetworkInfo.getType();
            switch (type) {
            case ConnectivityManager.TYPE_WIFI:
                result = NETWORK_WIFI;/*from w ww . jav  a  2  s  .co  m*/
                break;

            case ConnectivityManager.TYPE_BLUETOOTH:
                result = NETWORK_BLUETOOTH;
                break;

            case ConnectivityManager.TYPE_ETHERNET:
                result = NETWORK_ETHERNET;
                break;

            case ConnectivityManager.TYPE_MOBILE:
            case ConnectivityManager.TYPE_MOBILE_DUN:
            case ConnectivityManager.TYPE_MOBILE_HIPRI:
            case ConnectivityManager.TYPE_MOBILE_MMS:
            case ConnectivityManager.TYPE_MOBILE_SUPL:
                result = telManager.getNetworkType();
                break;
            }
        }
    }

    /* detect change from wifi to mobile or reverse */
    final int lastNetworkType = this.lastNetworkType.get();
    if (result != TelephonyManager.NETWORK_TYPE_UNKNOWN
            && lastNetworkType != TelephonyManager.NETWORK_TYPE_UNKNOWN) {
        if ((result == ConnectivityManager.TYPE_WIFI && lastNetworkType != ConnectivityManager.TYPE_WIFI)
                || (result != ConnectivityManager.TYPE_WIFI
                        && lastNetworkType == ConnectivityManager.TYPE_WIFI))
            illegalNetworkTypeChangeDetcted.set(true);
    }
    if (result != lastNetworkType) {
        this.lastNetworkType.set(result);
        if (telListener != null)
            telListener.onSignalStrengthsChanged(null);
    }

    return result;
}

From source file:com.ubiLive.GameCloud.Browser.WebBrowser.java

private void processNetworkType(Intent intent, Context context) {
    int netType;/*from   ww w. j ava  2s . c om*/
    int netSubtype;
    int networkType;
    boolean isConnected;
    String reloadUrl;
    DebugLog.d(TAG, "processNetworkType() enter");

    NetworkInfo netInfo = Utils.getCurNetworkInfo(context);
    if (netInfo == null || netInfo.isAvailable() == false) {
        DebugLog.d(TAG, "getCurNetworkInfo() is null");
        netInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
    }

    if (netInfo == null || netInfo.isAvailable() == false) {
        DebugLog.d(TAG, "getCurNetworkInfo() netInfo is null line1383");
        if (mbNetworIsConnect != false) {
            mbNetworIsConnect = false;
            reloadUrl = GameInfo.getErrorUrl();
            reload(reloadUrl);
        }
        Utils.setNetworkType(Constants.NETWORKTYPE_NONE);
        return;
    }
    netType = netInfo.getType();
    netSubtype = netInfo.getSubtype();
    isConnected = netInfo.isConnected();
    DebugLog.e(TAG, "======processNetworkType nettype = " + netType + ",netSubtype = " + netSubtype
            + ",isConnect = " + isConnected);
    switch (netType) {
    case ConnectivityManager.TYPE_MOBILE_SUPL:
    case ConnectivityManager.TYPE_MOBILE_MMS:
    case ConnectivityManager.TYPE_MOBILE_HIPRI:
    case ConnectivityManager.TYPE_MOBILE_DUN:
    case ConnectivityManager.TYPE_MOBILE:
        DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_MOBILE netSubtype=" + netSubtype);
        if (netSubtype == TelephonyManager.NETWORK_TYPE_LTE) {//4
            DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_MOBILE 4G");
            networkType = Constants.NETWORKTYPE_LTE;
        } else {//3
            DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_MOBILE 3G");
            networkType = Constants.NETWORKTYPE_3G;
        }
        break;
    case ConnectivityManager.TYPE_WIFI:
        DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_WIFI");
        networkType = Constants.NETWORKTYPE_WIFI;
        break;
    case ConnectivityManager.TYPE_ETHERNET:
        DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_ETHERNET");
        networkType = Constants.NETWORKTYPE_ETHERNET;
        break;
    default:
        DebugLog.d(TAG, "other network status");
        networkType = Constants.NETWORKTYPE_OTHERS;
        break;
    }
    DebugLog.e(TAG, "======processNetworkType nettype = " + netType + ",netSubtype = " + netSubtype
            + ",isConnect = " + isConnected + ",mbNetworIsConnect = " + mbNetworIsConnect);
    if (isConnected) {
        reloadUrl = Utils.checkUrl(GameInfo.DEFAULT_URL);
        Utils.setNetworkType(networkType);
        //         Utils.setNetworkType(Constants.NETWORKTYPE_WIFI);//temp change
    } else {
        reloadUrl = GameInfo.getErrorUrl();
        Utils.setNetworkType(Constants.NETWORKTYPE_NONE);
    }

    //      if((networkType == Constants.NETWORKTYPE_WIFI || networkType == Constants.NETWORKTYPE_LTE) && mbNetworIsConnect != isConnected){
    if (mbNetworIsConnect != isConnected) {
        mbNetworIsConnect = isConnected;
        reload(reloadUrl);
        DebugLog.d(TAG, "Notify reload finish");
    }
}

From source file:com.shinymayhem.radiopresets.ServiceRadioPlayer.java

protected int getConnectionType() {
    int newState = mNetworkInfo.getType();
    if (LOCAL_LOGV) {
        String str = "";

        switch (newState) {
        case ConnectivityManager.TYPE_WIFI:
            str += "wifi";
            break;
        case ConnectivityManager.TYPE_MOBILE:
            str += "mobile";
            break;
        case ConnectivityManager.TYPE_MOBILE_DUN:
            str += "mobile-dun";
            break;
        case ConnectivityManager.TYPE_MOBILE_HIPRI:
            str += "moblie-hipri";
            break;
        case ConnectivityManager.TYPE_MOBILE_MMS:
            str += "mobile-mms";
            break;
        case ConnectivityManager.TYPE_MOBILE_SUPL:
            str += "mobile-supl";
            break;
        case ConnectivityManager.TYPE_WIMAX:
            str += "wimax";
            break;
        case ConnectivityManager.TYPE_ETHERNET:
            str += "ethernet";
            break;
        case ConnectivityManager.TYPE_BLUETOOTH:
            str += "bluetooth";
            break;
        case ConnectivityManager.TYPE_DUMMY:
            str += "dummy";
            break;
        }// ww  w .j av  a  2s  .co m
        str += " detected";
        log(str, "v");
    }
    return newState;
}

From source file:com.chen.emailsync.SyncManager.java

/**
 * Taken from ConnectivityManager using public constants
 */// w  w w  .ja  v  a2  s  .  com
public static boolean isNetworkTypeMobile(int networkType) {
    switch (networkType) {
    case ConnectivityManager.TYPE_MOBILE:
    case ConnectivityManager.TYPE_MOBILE_MMS:
    case ConnectivityManager.TYPE_MOBILE_SUPL:
    case ConnectivityManager.TYPE_MOBILE_DUN:
    case ConnectivityManager.TYPE_MOBILE_HIPRI:
        return true;
    default:
        return false;
    }
}