网络运营STM
网络运营STM1、获取运营商名字获取运营商名字operatorName=中国移动;setText(中国移动);此卡属于(中国移动),operatorName=中国联通;setText(中国联通);此卡属于(中国联通),operatorName=中国电信;setText(中国电信);此卡属于(中国电信),获取网络类型获取网络信号类型NETWORK_TYPE_EVDO_0联通3G2g
1、获取运营商名字
/**
* 获取运营商名字
*/
private void getOperatorName() {
String operator = telephonyManager.getSimOperator();
if (operator != null) {
if (operator.equals(“46000”) || operator.equals(“46002”)) {
// operatorName=”中国移动”;
signalTextView.setText(“中国移动”);
// Toast.makeText(this, “此卡属于(中国移动)”,
// Toast.LENGTH_SHORT).show();
} else if (operator.equals(“46001”)) {
// operatorName=”中国联通”;
signalTextView.setText(“中国联通”);
// Toast.makeText(this,”此卡属于(中国联通)”网络运营,
// Toast.LENGTH_SHORT).show();
} else if (operator.equals(“46003”)) {
// operatorName=”中国电信”;
signalTextView.setText(“中国电信”);
// Toast.makeText(this网络运营, “此卡属于(中国电信)”,
// Toast.LENGTH_SHORT).show();
}
}
}
2 获取网络类型
/**
* 获取网络信号类型
*
*/
private void getNetType() {
int networkType = telephonyManager.getNetworkType();
if (networkType == TelephonyManager.NETWORK_TYPE_UMTS
|| networkType == TelephonyManager.NETWORK_TYPE_HSDPA
|| networkType == TelephonyManager.NETWORK_TYPE_EVDO_0
|| networkType == TelephonyManager.NETWORK_TYPE_EVDO_A) {
/ 联通3G
netTypeTextView.setText(“3G”);、} else if (networkType == TelephonyManager.NETWORK_TYPE_GPRS
|| networkType == TelephonyManager.NETWORK_TYPE_EDGE
|| networkType == TelephonyManager.NETWORK_TYPE_CDMA) {
// 2g
netTypeTextView.setText(“2G”);
} else {
netTypeTextView.setText(“”);
}
}