当前位置: 代码迷 >> Android >> android怎么判断是否支持3G
  详细解决方案

android怎么判断是否支持3G

热度:117   发布时间:2016-05-01 22:20:34.0
android如何判断是否支持3G?
如题

------解决方案--------------------
TelephonyManager telMgr=(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
telMgr.getNetworkCountryIso();//获取电信网络国别
telMgr.getPhoneType();//获得行动通信类型
telMgr.getNetWorkType();//获得网络类型
------解决方案--------------------
TelephonyManager telmanager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
int typ = telmanager.getNetworkType();
String type = "";
if (typ == TelephonyManager.NETWORK_TYPE_EDGE)
type = "EDGE"; //2.75G
if (typ == TelephonyManager.NETWORK_TYPE_GPRS)
type = "GPRS"; //2G
if (typ == TelephonyManager.NETWORK_TYPE_UMTS)
type = "UTMS"; //3G
if (typ == TelephonyManager.NETWORK_TYPE_UNKNOWN)
type = "UNKNOWN";


记住添加权限,不然报错。
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
  相关解决方案