aggregation of contacts

contact aggregation

Search Google for: contact aggregation

Search Android Developers Group for: contact aggregation

Search Android Beginers Group for: contact aggregation

Search Google Code for: contact aggregation

Search Android Issues Database for: contact aggregation

few notes on contact look up uri

A must read on how lookupkeys are formed

Find subsequently what is posted here.

Lookup key is unique at any point in time. It's not unique over time.

The anatomy of a lookup key is basically this. If an aggregate contact has three raw contacts with server-side IDs "A", "B" and "C", the lookup key will effectively be accountA/A.accountB/B.accountC/C

contact ID, which will be the one containing the most of the original raw contacts

Lookup key is unique at any point in time. It's not unique over time.

The anatomy of a lookup key is basically this. If an aggregate contact has three raw contacts with server-side IDs "A", "B" and "C", the lookup key will effectively be accountA/A.accountB/B.accountC/C

We don't attempt to find a contact with that exact lookup key. We actually parse it, find all those three raw contacts and infer the id of the new contact ID, which will be the one containing the most of the original raw contacts. In other words, even though the result is a bit unpredictable, the user shouldn't be surprised by what they see. The original contact had A, B and C - now I am looking at something that has either A or B or C or a couple of those or maybe A,B,C and D.

You are right that you should not use lookup keys to compare contact identities to each other. You can use the ContactsContract.Contacts.lookupContact(resolver, lookupUri) method, which will give you the current contact ID for your contact. Be careful though - between the moment you get it and the moment you use it the contact may change. Any kind of background sync could cause this change to happen. I would try to design the software in such a way that either doesn't need to do this type of resolution or uses something even more robust than lookup keys, e.g. raw contact IDs.

can tell you what we did when we faced a similar requirement. We needed to store things like custom ringtone, "straight-to-voicemail" etc on a per-contact basis. What we ended up doing is simply replicating this information into each raw contact in the aggregate. When raw contacts are re-aggregated, we use a heuristic to figure out the values for the entire aggregate (e.g. if one of the raw contacts has straight-to-voicemail=false, then the entire contact has straight-to-voicemail=false).

I would do the same in your case. You can always get _ids of all raw contacts in an aggregate contact and then in your database have a row for each of those raw contacts. To retrieve the information for an aggregate contact, you would pull it for all constituent raw contacts and use an algorithm to "aggregate" the data.

Another meaty thread on contacts api

You can always delegate contact creation to the Contacts app using the ContactsContract.Intents.UI.Insert intent with extras. This will show the edit UI.


AccountManager am = AccountManager.get(getContext()); 
Account[] accounts = am.getAccounts();

SyncAdapterType[] syncs 
= ContentResolver.getContentService().getSyncAdapterTypes(); 

for (SyncAdapterType sync : syncs) 
{ 
     if (ContactsContract.AUTHORITY.equals(sync.authority) 
          && sync.supportsUploading()) 
     { 
          contactAccountTypes.add(sync.accountType); 
     } 
}

for (Account acct: accounts) 
{ 
   if (contactAccountTypes.contains(acct.type)) 
   { 
      contactAccounts.add(account); 
   } 
}

"Contacts" represents an aggregated contact

"RawContacts" represents a contact as it was inserted by the sync adapter.

RawContact has a CONTACT_ID field that binds it to a Contact.

"Data" represents everything about a RawContact: emails, phone numbers, notes, birthday, high school graduation year, you name it.

Data has a RAW_CONTACT_ID field that binds it a RawContact.

The other important field is MIMETYPE. That's what determines the kind of data stored in a Data row. Everything else is just convenience API.

Raw contacts can have group memberships. A GroupMembership is a row in the Data table. If you want to add a membership find the group you need and add a row to the Data table with mimetype GroupMembership.CONTENT_ITEM_TYPE and the id of the group:

Regarding photos: are you setting the IS_SUPER_PRIMARY flag on your Photo row? The notion of "super-primary" has to do with multiple accounts. You can have only one super-primary photo for an entire aggregated contact.

- Deleting an aggregated contact will delete all constituent raw contacts

- Deleting all constituent raw contacts will delete the aggregated contact

- Deleting a raw contact automatically deletes all constituent data rows.

- This is a technical detail, but resolver.delete(...), does not physically delete a raw contacts row. It sets the DELETED flag on the raw contact.

The sync adapter then deletes the raw contact from the server and finalizes phone-side deletion by calling resolver.delete(...) again and passing the CALLER_IS_SYNCADAPTER query parameter.

A sync adapter is a service whose job is to sync data between a back end and the phone. It is typically kicked-off automatically on a schedule. Sync adapters are managed by sync manager, which knows when to start them, avoids running multiple at the same time and does a bunch of other useful stuff. You will want to inherit from android.content.AbstractThreadedSyncAdapter.

Also, see if it makes sense for you to have a separate account. Then instead of dropping new contacts to the Gmail or Exchange servers you would just bring them to the phone. Your contacts will get nicely aggregated with other contacts on the phone.

http://code.google.com/p/libs-for-android/

writing sync adapter part 1

and part 2

sourceconstraints xml

Search Google for: sourceconstraints xml

Search Android Developers Group for: sourceconstraints xml

Search Android Beginers Group for: sourceconstraints xml

Search Google Code for: sourceconstraints xml

Search Android Issues Database for: sourceconstraints xml

locate source code for contacts application

source code for android contacts application

Search for: source code for android contacts application

sample sync provider from google

Displaying a android contact from two accounts

Search Google for: Displaying a contact from two accounts

Search Android Developers Group for: Displaying a contact from two accounts

Search Android Beginers Group for: Displaying a contact from two accounts

Search Google Code for: Displaying a contact from two accounts

Search Android Issues Database for: Displaying a contact from two accounts

you will see icon (photo id), display name (borrowed from one of the raw contacts).

A contact may have more than one raw contact. which contact is to choose as the primary?? In a manual case you have the option. Not sure how this play out in auto mode.

May be there is a primary account.

rules for android contact aggregation

Search for: rules for android contact aggregation

contact details will likely come from contact_entities_view

lookup key is roughly a concatenation of the raw contact ids. So given a/b/c where a, b, c are raw contacts.

if "c" flies away fromt his flock, then the contact id based on the look up key will be one pointing to "a" and "b".

contacts overlappling fields

Search Google for: contacts overlappling fields

Search Android Developers Group for: contacts overlappling fields

Search Android Beginers Group for: contacts overlappling fields

Search Google Code for: contacts overlappling fields

Search Android Issues Database for: contacts overlappling fields

android contacts tutorial external link

display contact from multiple accounts

Search Google for: display contact from multiple accounts

Search Android Developers Group for: display contact from multiple accounts

Search Android Beginers Group for: display contact from multiple accounts

Search Google Code for: display contact from multiple accounts

Search Android Issues Database for: display contact from multiple accounts

merge contacts

Search Google for: merge contacts

Search Android Developers Group for: merge contacts

Search Android Beginers Group for: merge contacts

Search Google Code for: merge contacts

Search Android Issues Database for: merge contacts

This is a good read

Contacts with same last names but single first name seem to be merged. May be this is a good way to test overlapping fields. Let me see.

another post on that same issue