使用同步适配器创建的自定义帐户类型创建联系人

时间:2014-04-01 10:04:17

标签: android android-syncadapter

我已为自己编写了自己的Sync Adapter。我可以将联系人显示在联系人应用中。但我无法使用android中的默认联系人应用程序为此帐户类型创建新的。

在创建联系人时,很难找到有关如何在默认联系人应用中列出要创建的帐户类型的任何信息

1 个答案:

答案 0 :(得分:3)

在Android中只有三种帐号。

1)Google帐户,

2)交换账户,

3)可写帐户,并且通过可写,这意味着您的contacts.xml文件应包含EditSchema标记。

关于EditSchema,以下网址中有一个很好的示例:

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.3_r1/packages/apps/Contacts/tests/res/xml/test_basic_contacts.xml

在android清单文件中,您应该为contacts.xml添加此元数据。

 </service>
 <service android:name="com.example.ContactsSyncAdapterService"      
android:enabled="true" android:exported="true" android:process=":contacts">
 <intent-filter>
<action android:name="android.content.SyncAdapter" /> 
</intent-filter>
<meta-data android:name="android.content.SyncAdapter"   
 android:resource="@xml/sync_contacts" />

// this meta-data for contact.xml  
<meta-data android:name="android.provider.CONTACTS_STRUCTURE"    
 android:resource="@xml/contacts" />
 </service>

这段代码对我有用..试试这个..抱歉迟到的答案。

但我希望对某人有所帮助。

相关问题