需要在AndroidManifest.xml中添加权限。
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
然后在Activity中加入
1.TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
2. StringBuilder sb = new StringBuilder();
3. sb.append("\nDeviceId(IMEI) = " + tm.getDeviceId());
4. sb.append("\nDeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion());
5. sb.append("\nLine1Number = " + tm.getLine1Number());
6. sb.append("\nNetworkCountryIso = " + tm.getNetworkCountryIso());
7. sb.append("\nNetworkOperator = " + tm.getNetworkOperator());
8. sb.append("\nNetworkOperatorName = " + tm.getNetworkOperatorName());
9. sb.append("\nNetworkType = " + tm.getNetworkType());
10. sb.append("\nPhoneType = " + tm.getPhoneType());
11. sb.append("\nSimCountryIso = " + tm.getSimCountryIso());
12. sb.append("\nSimOperator = " + tm.getSimOperator());
13. sb.append("\nSimOperatorName = " + tm.getSimOperatorName());
14. sb.append("\nSimSerialNumber = " + tm.getSimSerialNumber());
15. sb.append("\nSimState = " + tm.getSimState());
16. sb.append("\nSubscriberId(IMSI) = " + tm.getSubscriberId());
17. sb.append("\nVoiceMailNumber = " + tm.getVoiceMailNumber());
18. Log.e("info", sb.toString());