Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create contact with custom account type created using Sync Adapter

I have written my own Sync Adapter for android. I can make the contacts appear in the contacts app. But im unable to create new ones for this account type using the default Contact app in android.

It's very hard to find any information on how to get my own account type listed for creation in the default contacts app while creating a contact

like image 590
Mourice Avatar asked Oct 20 '22 11:10

Mourice


1 Answers

only three kind of account in android.

1) Google Account,

2) Exchange Account,

3) Writable account, and by writable, it means that your contacts.xml file should contain EditSchema tag.

And about EditSchema, there is a good sample in the following URL:

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

In android manifest file you should add this meta-data for 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>

This code work for me.. try this.. sorry for late answer.

But I hope it help for someone.

like image 195
stacktry Avatar answered Oct 27 '22 11:10

stacktry