Reputation: 1665
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
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
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