简体   繁体   中英

How to get phone number for GSM in android device

I want to show own phone number from android device with code like this

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

its working and show phone number when I use CDMA , but if I use GSM , its number didnt show , and if I check if setting-about phone-status-my phone number show "unknown" when I use GSM ,

Can u give me solution to show phone number from android device for GSM?? pleasee, thanks :)

There is no guaranteed solution to this problem because the phone number is not physically stored on all SIM-cards, or broadcasted from the network to the phone. This is especially true in some countries which requires physical address verification, with number assignment only happening afterwards. Phone number assignment happens on the network - and can be changed without changing the SIM card or device (eg this is how porting is supported). I know it is pain, but most likely the best solution is just to ask the user to enter his/her phone number once and store it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM