现在的位置: 首页 > 综合 > 正文

android判断手机号的运营商(二)

2014年09月13日 ⁄ 综合 ⁄ 共 574字 ⁄ 字号 评论关闭
       TextView tv=(TextView)findViewById(R.id.tv); 
        TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
      // 获取SIM卡的IMSI码
        String imsi = telManager.getSubscriberId();
        //半段IMIS中的MNC
        if(imsi!=null){ if(imsi.startsWith("46000") || imsi.startsWith("46002"))

        {//因为移动网络编号46000下的IMSI已经用完,所以虚拟了一个46002编号,134/159号段使用了此编号 //中国移动
        	tv.setText(imsi+"中国移动");

        }else if(imsi.startsWith("46001")){

        //中国联通
        	tv.setText(imsi+"中国联通");

        }else if(imsi.startsWith("46003")){

        //中国电信
        	tv.setText(imsi+"中国电信");

        } }

注意在Manifest.xml中添加权限:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

抱歉!评论已关闭.