GeeCON Prague 2014*
The moose likes Android and the fly likes android how to obtain the phone number of the machine through the interface? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Mobile » Android
Bookmark "android how to obtain the phone number of the machine through the interface?" Watch "android how to obtain the phone number of the machine through the interface?" New topic
Author

android how to obtain the phone number of the machine through the interface?

Regen Mark
Greenhorn

Joined: Mar 14, 2012
Posts: 6
android how to obtain the phone number of the machine through the interface?
anyone can help me?
Mohan Prasath
Ranch Hand

Joined: Jul 25, 2011
Posts: 38

Most of the time the following code would return null or your old SIM number. But it works some times

String phoneNo = ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)).getLine1Number();

You have to give the following permission in the AndroidManifest <uses-permission android:name="android.permission.READ_PHONE_STATE"/>


With regards,
Mohan Prasath
 
GeeCON Prague 2014
 
subject: android how to obtain the phone number of the machine through the interface?