Android examples for Network:Network Status
is Network Connected By 2G
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.telephony.TelephonyManager; public class Main { public static boolean isNetworkConnectedBy2G(Context context) { NetworkInfo networkInfo = ((ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE)) .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (networkInfo != null && networkInfo.isConnected()) { int subtype = networkInfo.getSubtype(); if (subtype == TelephonyManager.NETWORK_TYPE_GPRS || subtype == TelephonyManager.NETWORK_TYPE_EDGE || subtype == TelephonyManager.NETWORK_TYPE_CDMA) {// ???????2G return true; }//from ww w . ja va 2 s. c o m } return false; } }