【发布时间】:2019-10-24 15:59:03
【问题描述】:
我有一个应用程序,它有自己的一组联系人,这些联系人来自服务器。我正在将此联系人导出到本机联系人数据库。这样我就可以从电话簿中访问它。但是,我想让这些联系人在本机应用程序中可编辑。
我为此使用帐户验证器和同步适配器方法。
下面是我的sync-adapterxml
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="com.android.contacts"
android:supportsUploading="true"
android:userVisible="true"
android:accountType="com.example.myapp"
/>
设置android:supportsUploading="true"
此外,通过将以下标志设置为 0,将原始联系人和数据字段导出为非只读
android.provider.ContactsContract.RawContacts.RAW_CONTACT_IS_READ_ONLY
android.provider.ContactsContract.RawContacts.DATA_IS_READ_ONLY
我仍然没有看到在本机应用程序中编辑我的联系人的选项。 这里缺少什么?
提前致谢
[更新] 我正在使用下面的代码来检查联系人支持的帐户类型并且是可编辑的。
final SyncAdapterType[] syncs = ContentResolver.getSyncAdapterTypes();
for (SyncAdapterType sync : syncs) {
Log.d(TAG, "found SyncAdapter: " + sync.accountType);
if (ContactsContract.AUTHORITY.equals(sync.authority)) {
Log.d(TAG, "found SyncAdapter that supports contacts: " + sync.accountType);
if (sync.supportsUploading()) {
Log.d(TAG, "found SyncAdapter that supports contacts and is not read-only: " + sync.accountType);
// we'll now get a list of all accounts under that accountType:
Account[] accounts = AccountManager.get(this).getAccountsByType(sync.accountType);
for (Account account : accounts) {
Log.d(TAG, account.type + " / " + account.name);
}
}
}
}
我的应用帐户类型是非只读的,但仍然看不到编辑选项。请帮忙
【问题讨论】:
标签: android android-contacts android-syncadapter