我正在开发一个需要获取IMSI的应用程序.我用:
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imsi = mTelephonyMgr.getSubscriberId();
它适用于大多数手机,但一些手机只返回6位而不是15位.这是错误的.
任何人都知道以编程方式检索IMSI的另一种方法吗?其他APIS?方法?
问候
根据这篇文章你可以使用
String imsi = android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMSI);
但SystemProperties不能直接访问,所以你需要在这个问题的答案中使用其中一个技巧:android.os.SystemProperties在哪里
您可能还需要SystemProperties来源.
小智 6
第一:来自维基
IMSI通常以15位长数字表示,但可以更短
short是指14位数的旧版imsi模型.这与此无关
第二:它不依赖于手机,而是依赖于网络
它返回6位数,因为该特定手机上的Android软件配置为仅返回imsi的非个人识别部分 - 定义国家和网络运营商的前6位数字
小智 5
此代码在我的项目中效果很好。
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String imsi = telephonyManager.getSubscriberId();
并且不要忘记许可:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
| 归档时间: | 
 | 
| 查看次数: | 42346 次 | 
| 最近记录: |