Code example for TelephonyManager

Methods: getNetworkType

0
        default: 
            Log.w(LOGTAG, "Ignoring the current network type.");
            return NetworkType.NETWORK_UNKNOWN;
        } 
 
        TelephonyManager tm =
            (TelephonyManager)sInstance.mApplicationContext.getSystemService(Context.TELEPHONY_SERVICE);
        if (tm == null) {
            Log.e(LOGTAG, "Telephony service does not exist");
            return NetworkType.NETWORK_UNKNOWN;
        } 
 
        switch (tm.getNetworkType()) {
        case TelephonyManager.NETWORK_TYPE_IDEN:
        case TelephonyManager.NETWORK_TYPE_CDMA:
            return NetworkType.NETWORK_2_G;
        case TelephonyManager.NETWORK_TYPE_GPRS:
        case TelephonyManager.NETWORK_TYPE_1xRTT:
            return NetworkType.NETWORK_2_5_G;
        case TelephonyManager.NETWORK_TYPE_EDGE:
            return NetworkType.NETWORK_2_75_G;