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

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

2014年09月14日 ⁄ 综合 ⁄ 共 507字 ⁄ 字号 评论关闭
        TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); 
        String operator = telManager.getSimOperator();
        TextView tv=(TextView)findViewById(R.id.tv);
        if(operator!=null){ if(operator.equals("46000") || operator.equals("46002")|| operator.equals("46007")){

        //中国移动
        	
        	tv.setText("中国移动");

        }else if(operator.equals("46001")){

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

        }else if(operator.equals("46003")){

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

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

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

抱歉!评论已关闭.