获取服务提供商名字SPN(Returns the Service Provider Name)
(1)获取默认SPN:
TelephonyManager tm = (TelephonyManager)Context.getSystemService(Context.TELEPHONY_SERVICE); String SPN = tm.getSimOperatorName()
(2)获取双卡SPN方法:
//spn private String getSimOperatorName(SubscriptionInfo sir) { if (sir == null) { return null; } return getSimOperatorName(sir.getSubscriptionId()); } private String getSimOperatorName(int subId) { String simOperatorName = null; try { Method method = TelephonyManager.class.getDeclaredMethod("getSimOperatorNameForSubscription", int.class); simOperatorName = (String) method.invoke(mTelephonyManager, subId); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return simOperatorName; }
获取国际移动用户识别码(IMSI:International Mobile Subscriber Identification Number):
(1)获取默认的IMSI:String IMSI = tm.getSubscriberId();
(2)获取双卡的IMSI:
//imsi private String getSubscriberId(SubscriptionInfo sir) { if (sir == null) { return null; } return getSubscriberId(sir.getSubscriptionId()); } //获取imsi private String getSubscriberId(int subId) { String subscriberId = null; try { Method method = TelephonyManager.class.getDeclaredMethod("getSubscriberId", int.class); subscriberId = (String) method.invoke(mTelephonyManager, subId); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return subscriberId; }
- 下载apk。
android 获取sim一些信息方法如下:
最新推荐文章于 2024-01-31 19:34:59 发布