Android Question Cannot get contact name if number is "cell"

Shay

Well-Known Member
Licensed User
Longtime User
Hi

I have starnge issue
I am using this code:

B4X:
listOfContacts = MyContacts.GetAll
 
    For i=0 To listOfContacts.Size-1
    Contact1 = listOfContacts.Get(i)
    If Contact1.PhoneNumber = MyNumber Then
      MyFullName=Contact1.Name
....

and the starnge thing is if contact put the phone number in the "cell" field the number is not visible
(I cannot see the number while tracking the contact1 data
if the number is saved on the "other" field, the I can
I tried to use the phone map, but it is VERY slow to get the results

Basically I am writing some app, that when someone is sending me SMS (which I can get only his messgae and number and not his name) so I am taking the number from the SMS and trying to find in my entire contacts if number match to person, so I can display person name and not his number
 

bsnqt

Active Member
Licensed User
Longtime User
Hi Shay: I would suggest you to look at "ContactUtils" class and "ContentResolver" library, you then can retrieve all Contacts information very quickly with phone number, name...including the "invisible" contact. Look at field "data1". Erel has given some sample codes there as well.
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
update: I fixed this issue with the ContactUtils

B4X:
List1 = cu.FindContactsByPhone (MyNumber,True,True)

Thank you all for the help
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
I am using the ContactUtils class 1.05, and the above issue is back (or never gone)
I added new contact, and his phone was automatically added to "cell" and I cannot find the name by the phone number
I have android 4.1.2 (upgraded today, so I am not sure if it is related to the android version or to the class)

I am using:
B4X:
List1 = cu.FindContactsByPhone(MyNumber,True,True)
 
Upvote 0
Top