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

你离开我真会死。 提交于 2019-12-29 06:33:50

问题


Possible Duplicate:
How to fetch own mobile number in android

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


回答1:


try following code

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

and with following permission in your xml

READ_PHONE_STATE


来源:https://stackoverflow.com/questions/5163803/how-to-get-the-telephone-number-associated-with-the-sim-in-a-gsm-phone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!