We implemented Android's Account Manager and Sync Manager api to create contact sync. But when user selects our account while adding contact, it only displays Name fields and all other fields disappear.
Here is what I have in my manifest
<activity android:name=".AuthenticatorActivity" android:label="iAnywhere Login"
开发者_Go百科 android:theme="@android:style/Theme.Dialog"
android:excludeFromRecents="true"></activity>
<service android:name=".accounts.AuthenticationService">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator"></action>
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator">
</meta-data>
</service>
<service
android:name=".accounts.SyncService"
android:exported="true">
<intent-filter>
<action
android:name="android.content.SyncAdapter" />
</intent-filter>
<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter" />
</service>
This is what I have in my syncadapter.xml and authenticator.xml
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="com.android.contacts"
android:accountType="com.rahul.utility.contacts"
/>
Have seen people talk about this kind of issue while adding custom fields that it is a bug in Contact application. I also checked out the code of Exchange Email client in Android source code and they seems to be doing exactly same as what I did, but still when you select Add Contact for an Exchange account it shows up all the fields in the contact.
After a lot of research and looking into the Android code base I found that Android only checks the account type to be either of Google or Default for rendering all the fields. If the account type is of any other type, it only displays basic two fields. There are no work around to it apart from creating your own Contact Add / Edit screen (Sad! Really).
There was a possibility where Android could have provided an interface for others to return field types which they wanted on the screen but it is not implemented that way as of now.
精彩评论