How to define ContactsAccountType for a server like Exchange to allow user to edit in native contact app using syncadapters

微笑、不失礼 提交于 2020-01-16 08:59:14

问题


I am implementing SyncAdapter which sync data from Microsoft Exchange server to device native contact. However, exchange have some limitation on the DataKinds e.g only 3 email id allowed of each type Home, Work, Mobile etc. Similarly for other pre-defined MimeTypes. I want the native contact app to honour this while editing/creating a new contact. I have added follow meta-data to my syncadapter.xml

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

I have defined an EditSchema in contacts.xml as below:

<ContactsAccountType
    xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <EditSchema
        >
        <DataKind kind="name"
            maxOccurs="1"
            supportsDisplayName="true"
            supportsPrefix="true"
            supportsMiddleName="true"
            supportsSuffix="true"
            supportsPhoneticFamilyName="true"
            supportsPhoneticMiddleName="true"
            supportsPhoneticGivenName="true"
            >
        </DataKind>
        <DataKind kind="photo" maxOccurs="1" />
        <DataKind kind="phone" maxOccurs="3">
            <Type type="mobile" />
            <Type type="home" />
            <Type type="work" />
            <Type type="fax_work" />
            <Type type="fax_home" />
            <Type type="pager" />
            <Type type="other" />
            <Type type="custom"/>
            <Type type="callback" />
            <Type type="car" />
        </DataKind>
        <DataKind kind="email" maxOccurs="3">
            <Type type="home" />
            <Type type="work" />
            <Type type="other" />
            <Type type="mobile" />
        </DataKind>
        <DataKind kind="nickname" maxOccurs="1" />
        <DataKind kind="im" >
            <Type type="aim" />
            <Type type="msn" />
            <Type type="yahoo" />
            <Type type="skype" />
            <Type type="qq" />
            <Type type="google_talk" />
            <Type type="icq" />
            <Type type="jabber" />
            <Type type="custom" />
        </DataKind>
        <DataKind kind="postal" needsStructured="false" >
            <Type type="home" />
            <Type type="work" />
            <Type type="other" />
            <Type type="custom" />
        </DataKind>
        <DataKind kind="organization" maxOccurs="1" />
        <DataKind kind="website" />
        <DataKind kind="sip_address" maxOccurs="1" />
        <DataKind kind="note" maxOccurs="1" />
    </EditSchema>
</ContactsAccountType>

But the edit screen in Native doesn't seems to honour this. It is falling back to default edit window where user are allowed to edit/add without any limit. But i can't sync these back to my server as it is not support.

Where i am doing wrong ? Is this device dependent?

来源:https://stackoverflow.com/questions/56578688/how-to-define-contactsaccounttype-for-a-server-like-exchange-to-allow-user-to-ed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!