0

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();  
CopsOnRoad
  • 175,842
  • 51
  • 533
  • 380
SHIDHIN.T.S
  • 1,477
  • 3
  • 26
  • 55

2 Answers2

2

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

Community
  • 1
  • 1
cw fei
  • 1,504
  • 1
  • 15
  • 32
0

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

Community
  • 1
  • 1