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" />
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" />
android判断手机号的运营商,布布扣,bubuko.com
原文地址:http://blog.csdn.net/u011733020/article/details/38726773