0

如何使用代码获取 SIM 卡号?我试过这段代码,它没有返回任何数字

TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
mPhoneNumber = tMgr.getLine1Number();
4

3 回答 3

2

采用

TelephonyManager phoneManager = (TelephonyManager) 
getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = phoneManager.getLine1Number();

需要 READ_PHONE_STATE 权限。

于 2012-11-05T11:52:44.077 回答
0

试试下面的代码:

    TelephonyManager mTelephonyMgr =
    (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);

    String sDeviceID = mTelephonyMgr.getDeviceId();
    String sSimSerial = mTelephonyMgr.getSimSerialNumber(); 
String sSimlineNumber = mTelephonyMgr.getLine1Number(); 

设置以下权限

android.permission.READ_PHONE_STATE in Android Manifest file
于 2012-11-05T11:53:36.267 回答
0

试试这样。。

TelephonyManager telphMgr = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);

字符串 simSerialNumber = telphMgr.getSimSerialNumber();

参考:

http://developer.android.com/reference/android/telephony/TelephonyManager.html#getSimSerialNumber%28%29

于 2012-11-05T11:55:48.180 回答