How to get phone number of the device in android activity

Kuldeep picture Kuldeep · Feb 3, 2016 · Viewed 10.1k times · Source

Is there any way to get phone number of device, by using GoogleApiClient. I got email, now want phone number.

Answer

josedlujan picture josedlujan · Feb 3, 2016

Add this permission:

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

and later use this:

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

Note: This method - although one of the only ways to do it - is not reliable. It can return a false number, blank string, or even null.