SHIDHIN TS
SHIDHIN TS

Reputation: 1665

How to get the telephone number of the device

I want to retrieve telephone number of the current Device. Now I cannot get the telephone number. I have added READ_PHONE_STATE permission in manifest. Here is my code

TelephonyManager tMgr = (TelephonyManager) this.getSystemService(Context.
String mPhoneNumber = tMgr.getLine1Number();  

Upvotes: 0

Views: 3432

Answers (2)

cw fei
cw fei

Reputation: 1564

Code :

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

Required Permission:

<uses-permission android:name="android.permission.READ_PHONE_STATE"/> 

refer to link : Programmatically obtain the phone number of the Android phone

Upvotes: 2

user4728480
user4728480

Reputation:

You need to have stored the phone number on the SIM card, and there´s no other way to get your "own number".

Check this link

Upvotes: 0

Related Questions