zoukankan      html  css  js  c++  java
  • android 获取IMSI信息(判断是移动,联通,电信手机卡)

    首先我们需要知道手机IMSI号前面3位460是国家,紧接着后面2位00 02是中国移动,01是中国联通,03是中国电信。那么第一步就是先获取手机IMSI号码:代码如下

     1     /**
     2      *获取IMSI信息
     3      * @param context
     4      * @return
     5      */
     6     public static String getPhoneIMSI(Context context) {
     7         TelephonyManager mTelephonyMgr = (TelephonyManager) context
     8                 .getSystemService(Context.TELEPHONY_SERVICE);
     9          Log.v("LJC", "get getSubscriberId " + mTelephonyMgr.getSubscriberId());
    10         return mTelephonyMgr.getSubscriberId();
    11     }

    或: 

     1     /**
     2      * 检查是否电信手机卡
     3      * 
     4      * @return 电信卡 返回true否则false
     5      */
     6     public boolean checkSIMCarl(Context context) {
     7         boolean value = false;
     8         String IMSI = getPhoneIMSI(context);
     9         if (IMSI != null) {
    10             if (IMSI.startsWith("46003"))
    11                 value = true;
    12         }
    13         return value;
    14         // IMSI号前面3位460是国家,紧接着后面2位00 02是中国移动,01是中国联通,03是中国电信。其中
    15         // if (IMSI.startsWith("46000") || IMSI.startsWith("46002")) {
    16         // ProvidersName = "中国移动";
    17         // } else if (IMSI.startsWith("46001")) {
    18         // ProvidersName ="中国联通";
    19         // } else if (IMSI.startsWith("46003")) {
    20         // ProvidersName = "中国电信";
    21     }
  • 相关阅读:
    Spring IOC知识点一网打尽
    Spring中-IOC-Bean的初始化-循环依赖的解决
    原型模式(Prototype)
    生成器模式
    工厂模式
    单例模式
    查询性能优化
    索引
    sql游标的使用入门
    js和C#中的编码和解码
  • 原文地址:https://www.cnblogs.com/jenson138/p/4560123.html
Copyright © 2011-2022 走看看