How to get phone number of the device in android activity
10,163
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
.
Author by
Kuldeep
I am a student, pursuing B.Tech(engineering) in Computer Science.
Updated on June 14, 2022Comments
-
Kuldeep almost 2 years
Is there any way to get phone number of device, by using GoogleApiClient. I got email, now want phone number.
-
josedlujan over 8 yearsNot copy, i do this in my app a few days.
-
Louis Nguyen over 8 yearsSome device can not get phone number!
-
M090009 about 8 yearsDon't forget that you'll need to ask for permission
-
Azhar osws over 7 yearsI am getting null? what is the problem?
-
Erich García over 6 yearsSad, dont work for me, testing on Honor 9, and Sony Xperia