首页 > 系统 > Android > 正文

Android 判断SIM卡属于哪个移动运营商的实现代码

2019-10-24 21:02:02
字体:
来源:转载
供稿:网友
有时候我们需要在Android中获取本机网络提供商呢,这里简单分享下,方便需要的朋友
 

 

复制代码代码如下:

[java]
public String getProvidersName()
  {
    String str = "N/A";
    try
    {
      this.IMSI = this.telephonyManager.getSubscriberId();
      System.out.println(this.IMSI);
      if (this.IMSI.startsWith("46000"))
       str = "中国移动";  break;
      if (this.IMSI.startsWith("46002"))
       str = "中国移动"; break ;
      if (this.IMSI.startsWith("46001"))
        str = "中国联通";
      else if (this.IMSI.startsWith("46003"))
        str = "中国电信";
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
         return str;
  }

注意申明:
[java]
复制代码代码如下:

this.telephonyManager = ((TelephonyManager)paramContext.getSystemService("phone")); 

就这么简单。。。。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表