Android: TelephonyManager.getSimSerialNumber() returns null

亡梦爱人 提交于 2019-12-23 19:16:15

问题


in which cases this method returns a null reference? Can only depend on the sim card? Doesn't exist, in these cases, an alternative to retrieve an identification number of the latter?

Thanks to all!


回答1:


Please make sure whether you have added the following permission in the Android Manifest, if not please add this statement add try again.

<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>

Note: Add this permission tag outside the application tag..

Sample Snippet:

.....
.....
.....
</application>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-permission android:name="android......"/>
 ..........
 </manifest>

All the Best




回答2:


try the below code..i will help full for u..

TelehponyManager manager = (TelehponyManager)getSystemService(TELEPHONY_SERVICE);

String imei = manager.getDeviceId();

String imsi = manager.getSubscriberId();


来源:https://stackoverflow.com/questions/5552249/android-telephonymanager-getsimserialnumber-returns-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!