Android Question phoneID could not find phone Number, can you please help?

wmardian

Member
Licensed User
Longtime User
Dear All,

I already try searching in this forum, and all solution told me to use phoneId to get the phone number. But it seem i can not use this solution.. maybe there is something wrong with my code..

B4X:
Sub Button1_Click
   
    Dim ph As PhoneId
    Dim phoneNumber As String
   
    phoneNumber = ph.GetLine1Number
    Label1.Text = phoneNumber

Please find attached picture.. from my debug that show the value is just empty.

Your help will be very appreciated.
Thanks and Regards

bj65qv.jpg
 

mangojack

Well-Known Member
Licensed User
Longtime User
have you added the following permission to you manifest file ?

android.permission.READ_PHONE_STATE
 
Upvote 0

wmardian

Member
Licensed User
Longtime User
Thanks MangoJack..
Just add it soon after i got your advice...And.... Still No luck
the value is still empty..

Rgds
 
Upvote 0

wmardian

Member
Licensed User
Longtime User
Dear Erel,
I connect the IDE to my lenovo P780 with dual sim card.
But i also found another thread in this forum and they also have the same problem..

Thanks and Regards
 
Upvote 0

wmardian

Member
Licensed User
Longtime User
Dear Erel,
Many thanks.
GetLine1Number calls the native API to get the phone number. If the number is not available then it returns an empty string.

It is impossible to say why the number is considered not available in this case.

Do you have any idea what i should do now? or is there another way to do this? my lenovo P780 loaded with kitkat... :(

Thanks and regards
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
Hi,
Could the phone number not been returned only because the SIM card does not know it ? Some operators won't write the phone number into the SIM card.
 
Upvote 0

wmardian

Member
Licensed User
Longtime User
Hi lemonisdead,
if it is the case, then what should we do to get the number or the identity of the phone which always return valid value?

Rgds
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Hi lemonisdead,
if it is the case, then what should we do to get the number or the identity of the phone which always return valid value?

Rgds

You dont need the telephone-number to identify a device... You can use the imei and/or SubscriberID...
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

wmardian

Member
Licensed User
Longtime User
Dear Don,
We are still trying to find alternative to getDeviceID and getLine1Number because there are some device which do not return correct value using these method..


Rgds
 
Upvote 0

wmardian

Member
Licensed User
Longtime User
Hi Lemonisdead,
Thanks.. i will try to test it. Sorry for the late reply.. was busy for something else.
Will back to you with the result..

Rgds
 
Upvote 0
Top