is China Telecom 2G Network Connection - Android Network

Android examples for Network:Network Connection

Description

is China Telecom 2G Network Connection

Demo Code


//package com.java2s;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import android.telephony.TelephonyManager;

public class Main {

    public static final int NETWORK_TYPE_NO_CONNECTION = -1231545315;

    public static boolean isChinaTelecom2G(Context context) {
        return isCDMABySubtype(context);
    }//from  w w w  .  j av  a  2 s.  co  m

    public static boolean isCDMABySubtype(Context context) {
        return getCurrentNetworkSubtype(context) == TelephonyManager.NETWORK_TYPE_CDMA;
    }

    public static int getCurrentNetworkSubtype(Context context) {
        NetworkInfo networkInfo = ((ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE))
                .getActiveNetworkInfo();
        return networkInfo != null ? networkInfo.getSubtype()
                : NETWORK_TYPE_NO_CONNECTION;
    }
}

Related Tutorials