Android Question Phone Number of Device

Intelemarketing

Active Member
Licensed User
Longtime User
I have a need to access the phone number of the Phone running my app.
I have found so many, many references to Phone on the forum, but none that tell me what the phone number of the phone is

Any ideas please
 

Alex_197

Well-Known Member
Licensed User
Longtime User
B4X:
Dim pi As PhoneId
Log(pi.GetLine1Number)

But you need to check for permission

B4X:
dim rp As RuntimePermissions
rp.PERMISSION_READ_PHONE_STATE
 

Attachments

  • GetPhoneNumber.zip
    9.4 KB · Views: 190
Upvote 0

Intelemarketing

Active Member
Licensed User
Longtime User
B4X:
Dim pi As PhoneId
Log(pi.GetLine1Number)

But you need to check for permission

B4X:
dim rp As RuntimePermissions
rp.PERMISSION_READ_PHONE_STATE

The Example Worked but displayed BLANK as the phone number

Also Warning:
The recommended value for android:targetSdkVersion is 29 or above (manifest editor). (warning #31)
 
Upvote 0

Intelemarketing

Active Member
Licensed User
Longtime User
Still no joy - I am running an oppo A7 with Android version 9, with and option for 2 sim cards (but I only have one installed)

No worries - Thanks for you help
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
tips:

 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
PhoneId in huawei Y9 android 9

does not show the phone number in dual SIM

1601744115763.png
 
Upvote 0

Intelemarketing

Active Member
Licensed User
Longtime User
Hi oparra - Not happy on my phone - Since the results appear to be random and inconsistent, it appears that the easiest solution is to get the User to key in their phone number. This is akin to what happens when a website asks you to key in your email address to validate that you are who you say you are. This will be fine for what I have in mind.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
yes.

if better ask for the phone number.

For security policies, it is with the consent of the user.

In most applications, they ask the user to enter the phone number.
 
Upvote 0
Top