1获取手机运营商现在主流的方法就读取手机的sim卡的IMSI码。它是sim卡的唯一标识,IMSI估计移动用户识别码,是区别。(International Mobile Subscriber Identification Number),它储存在SIM卡中,SIMI卡由MCC、MNC、MSIN组成,其中MCC为移到国家号码,由三位数字组成,用于标识移动客户所属的国家,我国为460、MNC为我网络ID,由2位数字组成,用于标识客户所归属的移动网络,中国移到为00,中国联通为01,中国电信为03。NSIN为客户识别码,采用等长11位数字组成,唯一标识国内GSM移动通信网络中的用户,所有要区分是联通还是移动,只需要取得SIM卡中的MNC字段即可。移到的00字段占用完了,因此借用了02字段因此这2个都是移动用户。
下面就给出我获取的代码:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TelephonyManager telmanager= (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String st=telmanager.getSubscriberId();
if(st!=null)
{
if(st.startsWith("46000")||st.startsWith("46002"))//移到的46000字段占用完了,因此借用了460002字段因此这2个都是移动用户。
System.out.println("中国移到");
else if(st.startsWith("46001"))
System.out.println("中国联通");
else if(st.startsWith("46003"))
System.out.println("中国电信");
}
}
}