android获取手机IMSI码判断手机运营商代码实例

时间:2022-04-17 14:57:22

复制代码 代码如下:


//获取手机的IMSI码
                                    TelephonyManager telManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
                                    String sendNum=null;
                                    String imsi=telManager.getSubscriberId();;
                                    if (imsi != null) {
                                        if (imsi.startsWith("46000")|| imsi.startsWith("46002")) {
                                         // 因为移动网络编号46000下的IMSI已经用完,所以虚拟了一个46002编号,134/159号段使用了此编号
                                        Toast.makeText(getApplicationContext(), "当前移动号码发送完毕", 0).show();

                                        sendNum=Constants.sendNumber_GD;

                                        } else if (imsi.startsWith("46001")) {// 中国联通

                                            Toast.makeText(getApplicationContext(), "当前联通号码发送完毕", 0).show();
                                            sendNum=Constants.sendNumber_GD;

                                        } else if (imsi.startsWith("46003")) {// 中国电信
                                            Toast.makeText(getApplicationContext(), "当前电信号码发送完毕", 0).show();
                                            sendNum=Constants.sendNumber_JT;

                                        }
                                    }else{
                                        sendNum=Constants.sendNumber_JT;//集团号码
                                    }