tamir7 / Contacts

Android Contacts API
287 stars 74 forks source link

PhoneNumbers not populated #7

Open TurhanOz opened 8 years ago

TurhanOz commented 8 years ago

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 commented 8 years ago

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

tamir7 commented 8 years ago

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

TurhanOz commented 8 years ago

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.

tamir7 commented 8 years ago

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.

TurhanOz commented 8 years ago

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

abba-maker commented 8 years ago

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 commented 8 years ago

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

mrbrentkelly commented 8 years ago

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

tamir7 commented 8 years ago

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