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("");
  }

 }

 

更多相关文章

  1. android为HttpClient和HttpURLConnection添加中国移动代理
  2. 中国移动开发者社区专访:学习Android的两大法宝
  3. 中国电信已加盟Android阵营

随机推荐

  1. 苦逼啊--qt for android 5.4.1 camera
  2. android canvas使用line画半园
  3. android下载安装APK
  4. android 监听其它app的错误或者崩溃的方
  5. Android: activity的过渡动画
  6. Android PhotoView 使用教程
  7. Android双击
  8. android menu自定义菜单 Demo
  9. android > 屏蔽掉返回键
  10. 第一代Android壳源码--某某公司早期壳代