Reputation: 245
I have tried below code
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();
Permission
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
I have tried in two device
Please help me !! Your help will be appreciated. Thanks in advance.
Upvotes: 3
Views: 2645
Reputation: 452
It is occurring because you need to set your own phone number on the device. please have a look at the below link.
getLine1Number() Returns blank, not null
This will solve your problem.
Upvotes: 1