android 獲取IMSI信息(判斷是移動,聯通,電信手機卡)

首先咱們須要知道手機IMSI號前面3位460是國家,緊接着後面2位00 02是中國移動,01是中國聯通,03是中國電信。那麼第一步就是先獲取手機IMSI號碼:代碼以下ide

 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     }

或: spa

 

 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     }
相關文章
相關標籤/搜索