android 擷取IMSI資訊(判斷是移動,聯通,電信手機卡),androidimsi

來源:互聯網
上載者:User

android 擷取IMSI資訊(判斷是移動,聯通,電信手機卡),androidimsi

首先我們需要知道手機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     }

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.