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" />