我写了一个自定义同步适配器,它还向 rawcontacts 添加了一个自定义字段。在SampleSyncAdapter中或在本示例中使用 last.fm-App 时,它是如何完成的。它在模拟器上运行良好。
声明我的自定义字段的 xml 文件:
<ContactsSource xmlns:android="http://schemas.android.com/apk/res/android">
<ContactsDataKind
android:mimeType="vnd.com.google.cursor.item/vnd.alien.mimetype"
android:icon="@drawable/icon"
android:summaryColumn="data2"
android:detailColumn="data3"
android:detailSocialSummary="true" />
</ContactsSource>
将自定义字段添加到 contactscontract-provider 的数据表中的代码:
mContentUri = Data.CONTENT_URI.buildUpon().appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true").build();
Builder mID = ContentProviderOperation.newInsert(mContentUri)
.withValue(Data.RAW_CONTACT_ID, getRawContactId())
.withValue(Data.MIMETYPE, "vnd.com.google.cursor.item/vnd.alien.mimetype")
.withValue(Data.DATA1, mContactInformations.get("mID"))
.withValue(Data.DATA2, mContext.getString(R.string.profile_text))
.withValue(Data.DATA3, mContext.getString(R.string.profile_id)+" "+mContactInformations.get("mID"));
但是当我在安装了 HTC Sense 的 HTC Desire 上运行它们时,我再也看不到这个自定义字段了?!?有没有人遇到过同样的问题?
任何让我的自定义字段可见的提示都非常感谢!
干杯 Ali3n