Android reads the user number mobile phone serial number SIM card serial number implementation code
- 2020-05-17 06:28:40
- OfStack
1. Using the method provided by TelephonyManager, the core code:
TelephonyManager tm = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);
String imei = tm.getDeviceId(); // Take out the IMEI
Log.d(TAG, "IMEI:"+imei);
String tel = tm.getLine1Number(); // Take out the MSISDN Is probably empty
Log.d(TAG, "MSISDN:"+tel);
String iccid =tm.getSimSerialNumber(); // Take out the ICCID
Log.d(TAG, "ICCID:"+iccid);
String imsi =tm.getSubscriberId(); // Take out the IMSI
Log.d(TAG, "IMSI:"+imsi);
2. Access
In the manifest.xml file to add < uses-permission android:name="android.permission.READ_PHONE_STATE" / >