How to match a contact with a phone number that uses a country code using a search string that does not use the country code? #258
-
I want to find the details of a saved phone number. I have a phone number "03004481849" which is saved in my contacts. When I try to find it with
But when I try to find this contact using
It returns the cursor with the result and I can read it. Is it a bug in the library because it can't find it? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
I just checked your source code you are using For more details you can look at this question |
Beta Was this translation helpful? Give feedback.
-
@mianaliasjad, I am currently unable to reproduce this issue using the following code you provided; val contact = Contacts(context)
.broadQuery()
.match(BroadQuery.Match.PHONE)
.wherePartiallyMatches( "03004481849" )
.limit(1)
.find()
.firstOrNull() I created a contact with the phone number "03004481849" and I am able to get it.
Maybe. I'm not sure until I can reproduce it. There are a few things I want you to try to help me figure if this is a bug or not. First, could you make sure that you have the val contact = Contacts(context)
.broadQueryWithPermission()
.match(BroadQuery.Match.PHONE)
.wherePartiallyMatches( "03004481849" )
.limit(1)
.find()
.firstOrNull() If permissions is not the issue, please provide me more data. It would really help if you give me the logs to the Contacts Provider database tables. Before you copy and paste the logs here in public for everyone to see, please make sure there are no sensitive data there. You can make sure of this by using fake data. Read this page on how to do this; https://vestrel00.github.io/contacts-android/debug/debug-contacts-provider-tables/ Essentially, you just have to use the |
Beta Was this translation helpful? Give feedback.
-
Yes, Contacts permission is granted. I am testing on the Samsung s22 ultra |
Beta Was this translation helpful? Give feedback.
-
Ok i found a hint for you: Let's suppose a number with a country code is saved "+923123456789" but when i try to find it without country code "03123456789" the library is unable to find it. But my method using |
Beta Was this translation helpful? Give feedback.
-
For future readers, currently, there is no proper way in this library to find the details of contact with the given phone number. Let's suppose you want the details of contact with the number "0347".
It will return the details of all the numbers that end with "****0347" which is not desired because we want details for "0347" exact number. So as @vestrel00 described we should add a new feature called |
Beta Was this translation helpful? Give feedback.
Ok i found a hint for you:
Let's suppose a number with a country code is saved "+923123456789" but when i try to find it without country code "03123456789" the library is unable to find it.
But my method using
ContactsContract.PhoneLookup.CONTENT_FILTER_URI
i can find it.