tags:

views:

12

answers:

0

Hello,

I need to fix a bug in an old app of mine. Part of the bug is how I select contacts. Here is what I need:

  1. The contact must be from the 'normal' google contacts list, i.e. I don't want to get any contacts from facebook or similar.
  2. The contact must have at least one phone number.
  3. The contact must be from the old android.provider.Contacts provider.
  4. If I can use an Intent to fetch the contact URI without having to create the selection list etc myself, then that is a bonus.

Sounds simple, but I am really struggling. This is what I am trying:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = new Intent(Intent.ACTION_PICK, Contacts.People.CONTENT_URI);
    startActivityForResult(intent, PICK_CONTACT_REQUEST);
}

That works OK. I still see contacts without phone numbers, but I can live with that. Worse though is that I still see facebook contacts in the list! This seems to be in contradiction to the following quote found at the Froyo API for the deprecated Contacts content provider:

The APIs have been superseded by ContactsContract. The newer APIs allow access multiple accounts and support aggregation of similar contacts. These APIs continue to work but will only return data for the first Google account created, which matches the original behavior.

That sounds like exactly what I wanted, but alas, not what I got.

Finally, here are my concrete questions that I hope someone can answer:

  1. Why am I seeing Facebook contacts when using the android.provider.Contacts content provider?
  2. If this doesn't work, how else can I get the user to select a google contact with a phone number?

Many thanks. Gustav