Android(安卓)识别SIM卡类型
16lz
2021-12-04
public class SimUtil {/** * 中国移动 */public static final int SIM_TYPE_CHINA_MOBILE = 1;/** * 中国联通 */public static final int SIM_TYPE_CHINA_UNICOM = 2;/** * 中国电信 */public static final int SIM_TYPE_CHINA_TELECOM = 3;/** SIM卡是中国移动 */public static boolean isChinaMobile() {String imsi = getSimOperator();if (imsi == null) return false;return imsi.startsWith("46000") || imsi.startsWith("46002") || imsi.startsWith("46007");}/** SIM卡是中国联通 */public static boolean isChinaUnicom() {String imsi = getSimOperator();if (imsi == null) return false;return imsi.startsWith("46001");}/** SIM卡是中国电信 */public static boolean isChinaTelecom() {String imsi = getSimOperator();if (imsi == null) return false;return imsi.startsWith("46003");}private static String getSimOperator() {TelephonyManager tm = (TelephonyManager)BoyaaApp.getApplication().getSystemService(Context.TELEPHONY_SERVICE);return tm.getSubscriberId();}/** 获取手机电话号码 */public static String getPhoneNumbers() {TelephonyManager tm = (TelephonyManager)BoyaaApp.getApplication().getSystemService(Context.TELEPHONY_SERVICE);return tm.getLine1Number();}//sim卡是否可读 public static boolean isCanUseSim() { try { TelephonyManager mgr = (TelephonyManager) BoyaaApp.getApplication().getSystemService(Context.TELEPHONY_SERVICE); return TelephonyManager.SIM_STATE_READY == mgr .getSimState(); } catch (Exception e) { e.printStackTrace(); } return false; } }
更多相关文章
- Android开始-3G应用之android
- android 打开/关闭 移动网络
- android APN的打开与关闭
- Android(安卓)APN设置
- android获取手机信息以及服务商信息
- 教你如何开关Android的APN网络
- 教你如何开关Android的APN网络
- 中国移动开发者社区专访:学习Android的两大法宝
- 教你如何开关Android的APN网络