Android Question How do I get the phone's number with B4A?

gregmatthews

Member
Licensed User
I've spent a long time reading posts on here, but still can't work out how to get the phone's number

To get the IMEI I can do this:
B4X:
Dim  pid as PhoneId
imei = pid.GetDeviceId

How do I get the phone's number?

Greg
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

gregmatthews

Member
Licensed User
Hi,
Thanks for the swift reply.
.GetDeviceId, .GetSubscriberId, and .GetSimSerialNumber all work and return a string of digits
.GetLine1Number returns nothing, a blank string

Anything else I can try?

G.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
The .GetLine1Number method only works if the the phone number is stored on the SIM card (which not all phone carriers do). I would get the user to enter their phone number on fist running of the app. From what I remember the phone number is not actually stored on the device anywhere either, but I could be wrong...
 
Last edited:
Upvote 0

gregmatthews

Member
Licensed User
Thanks Peter. I did find an old post from Erel saying that Line1 didn't work for all phones, and there are no work-arounds. It seems things haven't changed since that post, and so your answer in useful in saving futile hunting. I'll do as you say, try and get it automatically and if that's not possible, then prompt the user.
 
Upvote 0
Top