Post Reply

[GSM]Getting phone number programmatically

18th April 2014, 01:29 PM   |  #1  
poria1999's Avatar
OP Senior Member
Flag Tehran
Thanks Meter: 458
 
342 posts
Join Date:Joined: Feb 2013
More
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?
Last edited by poria1999; 18th April 2014 at 02:05 PM.
6th May 2014, 09:31 AM   |  #2  
Junior Member
Thanks Meter: 6
 
19 posts
Join Date:Joined: May 2014
Quote:
Originally Posted by poria1999

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: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Java for Android App Development by ThreadRank