问题
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