开发者

How to get the phone number of the phone in android code?

I tried googling in google but unable to find the answer

Will anyone please let me know, how can i retrieve the current phone number from the android code. I think phone number will be stored in the sim card.开发者_开发百科

Thanks & Regards, SSuman185


You can try:

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

Needs READ_PHONE_STATE permission.


TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
String phonenumber = tm.getLine1Number();

This link may be the best collection of TelephonyManager related answers. But still it is not guaranteed that you will be returned a telephone number.

Check this out!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜