Contacts icon indicating copy to clipboard operation
Contacts copied to clipboard

PhoneNumbers not populated

Open TurhanOz opened this issue 8 years ago • 9 comments

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

TurhanOz avatar Jun 22 '16 10:06 TurhanOz

Seems to be same as https://github.com/tamir7/Contacts/pull/5

TurhanOz avatar Jun 22 '16 10:06 TurhanOz

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();

tamir7 avatar Jun 22 '16 11:06 tamir7

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.

TurhanOz avatar Jun 22 '16 12:06 TurhanOz

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.

tamir7 avatar Jun 22 '16 13:06 tamir7

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

TurhanOz avatar Jul 04 '16 06:07 TurhanOz

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

abba-maker avatar Jul 16 '16 15:07 abba-maker

Or if you can fix the problem while using the normalizedPhoneNumber, it'll be even better.

abba-maker avatar Jul 16 '16 15:07 abba-maker

Seeing the same issue. Is there a permanent fix coming for this?

mrbrentkelly avatar Aug 11 '16 21:08 mrbrentkelly

Added phoneNumber field in 1.1.0 On API >= 16 you should have both phoneNumber and normalizedPhoneNumber.

tamir7 avatar Aug 17 '16 15:08 tamir7