本文介绍了获取网络类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在试图以检索当前的网络类型,但没有成功。
I've been trying to retrive the current network type, but no success
当我说网络类型:我指的是知道这个信息:如果类型为: NETWORK_TYPE_IDEN
或 NETWORK_TYPE_UMTS
..等..
when i say network type: i refer to know this info:if the type is: NETWORK_TYPE_IDEN
or NETWORK_TYPE_UMTS
.. and so on..
我试图用:
NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
或
NetworkInfo mobNetInfo = connectivityManager.getNetworkInfo
(ConnectivityManager.TYPE_MOBILE);
但没有成功。
but no success..
我做这怎么我想知道如果当前网络IDEN,或者当前网络通过无线连接。
i am doing this coz i wanna know if the current network is IDEN, or if the current network is connected through wifi..
推荐答案
这对我的作品来检查网络类型...
This works for me to check the network type...
TelephonyManager teleMan =
(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
int networkType = teleMan.getNetworkType();
switch (networkType)
{
case 7:
textV1.setText("1xRTT");
break;
case 4:
textV1.setText("CDMA");
break;
case 2:
textV1.setText("EDGE");
break;
case 14:
textV1.setText("eHRPD");
break;
case 5:
textV1.setText("EVDO rev. 0");
break;
case 6:
textV1.setText("EVDO rev. A");
break;
case 12:
textV1.setText("EVDO rev. B");
break;
case 1:
textV1.setText("GPRS");
break;
case 8:
textV1.setText("HSDPA");
break;
case 10:
textV1.setText("HSPA");
break;
case 15:
textV1.setText("HSPA+");
break;
case 9:
textV1.setText("HSUPA");
break;
case 11:
textV1.setText("iDen");
break;
case 13:
textV1.setText("LTE");
break;
case 3:
textV1.setText("UMTS");
break;
case 0:
textV1.setText("Unknown");
break;
}
这篇关于获取网络类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!