Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1105537
  • 博文数量: 276
  • 博客积分: 8317
  • 博客等级: 少将
  • 技术积分: 2329
  • 用 户 组: 普通用户
  • 注册时间: 2006-09-12 08:17
个人简介

http://ads.buzzcity.net/adpage.php?partnerid=40096

文章分类

全部博文(276)

文章存档

2013年(1)

2012年(38)

2011年(102)

2010年(85)

2009年(45)

2008年(5)

分类: 嵌入式

2011-10-25 14:11:00

第一种方法:
获取手机的IMSI码,并判断是中国移动\中国联通\中国电信
  1. TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);   
  2. /** 获取SIM卡的IMSI码  
  3.  * SIM卡唯一标识:IMSI 国际移动用户识别码(IMSI:International Mobile Subscriber Identification Number)是区别移动用户的标志,  
  4.  * 储存在SIM卡中,可用于区别移动用户的有效信息。IMSI由MCC、MNC、MSIN组成,其中MCC为移动国家号码,由3位数字组成,  
  5.  * 唯一地识别移动客户所属的国家,我国为460;MNC为网络id,由2位数字组成,  
  6.  * 用于识别移动客户所归属的移动网络,中国移动为00,中国联通为01,中国电信为03;MSIN为移动客户识别码,采用等长11位数字构成。  
  7.  * 唯一地识别国内GSM移动通信网中移动客户。所以要区分是移动还是联通,只需取得SIM卡中的MNC字段即可  
  8.  */   
  9. String imsi = telManager.getSubscriberId();   
  10. if(imsi!=null){   
  11.     if(imsi.startsWith("46000") ||imsi.startsWith("46002")){  
  12.     //因为移动网络编号46000下的IMSI已经用完,所以虚拟了一个46002编号,134/159号段使用了此编号   
  13.      //中国移动   
  14.     }else if(imsi.startsWith("46001")){   
  15.      //中国联通   
  16.     }else if(imsi.startsWith("46003")){   
  17.      //中国电信   
  18.     }   
  19. }   
第二种方法
  1. TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);   
  2.         String operator = telManager.getSimOperator();   
  3.  if(operator!=null){   
  4.         if(operator.equals("46000") || operator.equals("46002")){   
  5.          //中国移动   
  6.         }else if(operator.equals("46001")){   
  7.          //中国联通   
  8.         }else if(operator.equals("46003")){   
  9.          //中国电信   
  10.         }   
  11. }   
在文件AndroidManifest.xml中添加权限
阅读(520) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~