Contacts
Contacts copied to clipboard
PhoneNumbers not populated
Hello,
I'm making a simple query such as :
Query q = Contacts.getQuery();
List<Contact> contacts = q.find();
Some of the contacts don't have PhoneNumbers populated whereas it is filled on the System stock Contact application. Any idea ?... Cheers
Seems to be same as https://github.com/tamir7/Contacts/pull/5
You have Contacts in your phone that don't have a phone number. If you only want to get contacts that have phone numbers, change your query to:
Query q = Contacts.getQuery();
List<Contact> contacts = q.hasPhoneNumber().find();
What I was trying to say is that even contacts that have numbers don't have the phoneNumbers list populated. The PR https://github.com/tamir7/Contacts/pull/5 seems to fix that.
If you run the query you've written in your first comment, you will get contacts without phone numbers. If you add hasPhoneNumber() to the query, you shouldn't get contacts without phone number. PR #5 adds support for the old phoneNumber field. I don't use it in my code because it's not normalized and its hard to query agains it. As of API 16, there's a normalizedPhoneNumber field. It's better to work with it as all the numbers are normalized to E164 format. From API 16 the internal Contacts table has both fields.
Dear Tamir,
as per my previous comment, if I query with hasPhoneNumber(), some contacts won't be populated in the result even if they have phone numbers. This is certainly due to the normalized phone number field. The PR https://github.com/tamir7/Contacts/pull/5 solves that by adding support to the old api. As the mindset of open source projects, I think that even if you don't use this API on your code, it could be worth including this PR so people can choose which api to use. Cheers
Hello tamir,
TurhanOz is right, am currently experiencing same problem where I use hasPhoneNumber() but some contacts still don't have the phoneNumber field populated even though they have phone number. It'll be great if you could add the PR as he suggested.. Thanks
Or if you can fix the problem while using the normalizedPhoneNumber, it'll be even better.
Seeing the same issue. Is there a permanent fix coming for this?
Added phoneNumber field in 1.1.0 On API >= 16 you should have both phoneNumber and normalizedPhoneNumber.