代码改变世界

判断SIM卡所属的运营商

2011-07-19 00:04  shaobin0604  阅读(302)  评论(0编辑  收藏  举报
   1: TelephonyManager mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
   2: int simState = mTelephonyManager.getSimState();
   3: if (simState != TelephonyManager.SIM_STATE_READY) {
   4:     // unknown sim op
   5: }
   6:  
   7: String simOp = mTelephonyManager.getSimOperator();
   8: if ("46000".equals(simOp) || "46002".equals(simOp) || "46007".equals(simOp)) {
   9: // 移动
  10: } else if ("46001".equals(simOp)) {
  11: // 联通
  12: } else if ("46003".equals(simOp)) {
  13: // 电信
  14: }

需要权限  android.permission.READ_PHONE_STATE