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
  • 237,138
  • 77
  • 654
  • 440
SHIDHIN TS
  • 1,557
  • 3
  • 26
  • 58

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,534
  • 1
  • 15
  • 33
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