TelephonyManager tm = (TelephonyManager)Context.getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager 的使用 TelephonyManager 提供设备上获取通讯服务信息的入口,应用程序使用这个类的方法来获取电话的服务商或者状态。程序也可以注册一个监听器来监听电话状态的改变。不需要直接实例化这个类,使用Context.getSystemService(Context.TELEPHONY_SERVICE)来获取这个类的实例。
注意:一些电话信息需要相应的权限。方法无效
getSimOperatorName() Returns the Service Provider Name (SPN). // 获取服务提供商名字,比如电信,联通,移动用下面的方法第一种方法: 获取手机的IMSI码,并判断是中国移动/中国联通/中国电信
TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imsi = telManager.getSubscriberId();
if(imsi!=null){ if(imsi.startsWith(“46000″) || imsi.startsWith(“46002″))
{//因为移动网络编号46000下的IMSI已经用完,所以虚拟了一个46002编号,134/159号段使用了此编号 //中国移动
}else if(imsi.startsWith(“46001″)){