开发者

Android 1.x Contacts.Extensions for a custom account type?

I'm writing a social networking app that has contacts sync functionality. I have working code (from an example I found here) that inserts contacts on v2.x in a sync adapter.

However, the Motorola Blur software doesn't recognize 2.x contacts (I'm using a 2.2 Moto build on a Droid X). Blur开发者_Go百科 uses the contacts 1.x API, but I'm having trouble finding/understanding examples of how to use it. This page shows how to query by name, but I want to a) add and b) query by a custom account (or potentially MIME) type.

The v2 code I'm using creates a new raw contact, creates a "StructuredName" data record, and then a data record of custom MIME type.

How do I do the equivalent on the 1.x API (level 3)? I think that this is what the Contacts.Extensions class is for, but the documentation is unclear at best.


The Motorola BLUR modifications to contacts have more to do with how accounts are managed on the device and less with changes to the content provider. The real issue when working with a Motorola BLUR device is that you need to set the ACCOUNT_NAME and ACCOUNT_TYPE to a value that plays nice with the device.

Motorola isn't the only device for which this is an issue as in my work I have found other devices whose contacts applications don't play nice with records that are added to custom accounts on the device.

During setup, you'll have to determine what type of device you are running on and then make a determination of what account you will use to store your contacts. I have found exceptions for the Samsung Galaxy, HTC Sense devices and MOTOBLUR devices for which using a custom contact account doesn't allow you to work with your contacts in the contact application (for example, you can add them, but not edit or are unable to insert new records to your account).

I can't share code because it belongs to my work, but I can tell you that if you use the following account for your contacts on MOTOBLUR devices it will work. Motorola devices on Verizon have a backup assistant account that works great and other wise I use the default BLUR account which seems to work well.

Look for an account on the device with the type com.motorola.android.buacontactadapter and a name of "Phone" and use that. If that's not present, look for an account of the type com.motorola.blur.service.bsutils.MOTHER_USER_CREDS_TYPE and use that (with whatever its name is) and you'll be all set on Motorola devices.

If you share some of your code or a link to the example you referenced, I'd be happy to dive deeper.


To address the end of your question:

This infrastructure is only supported for 2.x contacts structure, that's when they introduced it.

OEM Contacts apps on 1.X devices may or may not work similarly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜