Android Question Get the Phone Number of the device

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

I would like to get the Phone/Mobile number of the device being used to run my app
I tried the following code
B4X:
Dim MyPhone As PhoneId
Dim cText as String

cText =  "1. Device ID : " & MyPhone.GetDeviceId &CRLF& _
         "2. Line1 Number : " & MyPhone.GetLine1Number &CRLF& _
         "3. SIM Serial No : " & MyPhone.GetSimSerialNumber  &CRLF& _
         "4. Subscriber ID : " & MyPhone.GetSubscriberId

MsgBox(cText,"Phone details")

I tried the above code on several devices. Only very few devices shows the Line1 Number. So this is not a reliable way to get the Mobile number of the device. All other information are working perfectly, the issue is only with the Line1Number.

I found an old post regarding this, from there I understand that there are no reliable ways. The last comment on that post is on Sept 2013. Is there any technique discovered after Sept 2013 to get the phone number of the device ?
https://www.b4x.com/android/forum/threads/is-it-possible-to-get-own-phone-number.7522/

Is there any other way to get the Phone Number of the device ?

I also tried a library named SimCard available on this forum, unfortunately even that library too failed to give the Phone number of the device.

I need to do a validation based on the phone number of the device.

Any help will be appreciated.

Regards
Anser
 
Last edited:
Top