1

我们实现了 Android 的 Account Manager 和 Sync Manager api 来创建联系人同步。但是当用户在添加联系人时选择我们的帐户时,它只显示名称字段,而所有其他字段都消失了。

这是我的清单中的内容

<activity android:name=".AuthenticatorActivity" android:label="iAnywhere Login"
            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>

这就是我的syncadapter.xml 和authenticator.xml 中的内容

<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
    android:contentAuthority="com.android.contacts"
    android:accountType="com.rahul.utility.contacts"
/>

已经看到人们在添加自定义字段时谈论此类问题,这是联系人应用程序中的错误。我还在 Android 源代码中检查了 Exchange 电子邮件客户端的代码,它们似乎与我所做的完全相同,但是当您为 Exchange 帐户选择添加联系人时,它仍会显示联系人中的所有字段。

4

1 回答 1

0

经过大量研究并查看 Android 代码库后,我发现 Android 仅检查帐户类型为 Google 或 Default 以呈现所有字段。如果账户类型是任何其他类型,它只显示基本的两个字段。除了创建您自己的联系人添加/编辑屏幕(可悲!真的)之外,没有其他解决方法。

有一种可能性是,Android 可以为其他人提供一个接口,以在屏幕上返回他们想要的字段类型,但目前还没有以这种方式实现。

于 2011-09-22T11:18:37.963 回答