如何获得与在GSM电话SIM卡相关联的电话号码?相关联、如何获得、电话号码、电话

2023-09-13 00:58:48 作者:为君舞尽倾世繁华

可能重复:   如何获取android的自己的手机号码

Possible Duplicate: How to fetch own mobile number in android

如何获得与SIM卡在GSM手机相关的电话号码?

How to get the telephone number associated with the SIM in a GSM phone?

推荐答案

试试下面的code

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

和与您的XML以下权限

and with following permission in your xml

READ_PHONE_STATE