1

我写了一个自定义同步适配器,它还向 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

4

2 回答 2

1

默认联系人查看器不显示自定义字段。

有一些 3rd 方应用程序会显示自定义字段,这里有一个免费的(但支持广告)

于 2012-02-19T09:41:17.867 回答
0

不幸的是,我没有找到真正的解决方案。但是有两件事可以减少问题:

这个问题只出现在我的旧 HTC Desire 上。在我的姐妹 HTC Sensation 上,自定义字段按预期显示(HTC 在第一次尝试 oO 时失败了)

更好的是,将通过此自定义字段启动的意图也显示在 QuickContactBadge 中,本机 HTC Contacts-App 甚至在我的 HTC Desires Sense 上也使用它。因此,用户可以在旧版 Senses 上通过 QuickContactBadge 调用我的活动,在新版本中,他还可以使用自定义字段。

于 2012-05-22T14:38:39.370 回答