Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,728,959 Members 44,668 Now Online
XDA Developers Android and Mobile Development Forum

[GSM]Getting phone number programmatically

Tip us?
 
poria1999
Old
(Last edited by poria1999; 18th April 2014 at 02:05 PM.)
#1  
poria1999's Avatar
Senior Member - OP
Thanks Meter 421
Posts: 336
Join Date: Feb 2013
Location: Tehran
Default [GSM]Getting phone number programmatically

hi
i am writing an app that needs to get sim cards phone number.
i tried this but its not working.
Code:
        TelephonyManager telemamanger = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        String getSimSerialNumber = telemamanger.getLine1Number();
it returns null....
i have tried every thing but nothing worked.
any help?
Experience The Awesomeness


 
GRYMALA
Old
#2  
Junior Member
Thanks Meter 6
Posts: 19
Join Date: May 2014
Quote:
Originally Posted by poria1999 View Post
hi
i am writing an app that needs to get sim cards phone number.
i tried this but its not working.
Code:
        TelephonyManager telemamanger = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        String getSimSerialNumber = telemamanger.getLine1Number();
it returns null....
i have tried every thing but nothing worked.
any help?

It should work, however there is no guarantee that phone number is physically stored on a SIM-card or broadcasted from the network to the phone.
Alternative solution might be to ask the user to enter phone number manually in case if telemamanger.getLine1Number() returns null.
The Following User Says Thank You to GRYMALA For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes