Can I know the phone number of the device by code?

Asked 2 years ago, Updated 2 years ago, 26 views

Is there a way to know the device's phone number on the returning app?

android telephonymanager phone-number

2022-09-22 16:08

1 Answers

First, go to the Android manifest file <uses-permission android:name="android.permission.READ_PHONE_STATE"/> Please allow permission for phone status.

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

It's accessible with these codes.


2022-09-22 16:08

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.