如何在android中启用自定义帐户同步?

发布于 2024-09-09 11:11:08 字数 1058 浏览 0 评论 0原文

我正在为 Android 设备编写自己的 SyncAdapter,它应该将电视广播信息同步到设备,但遇到了无法在“数据和数据”下看到同步“mydata”复选框的问题。帐户首选项的同步部分。

我已经实现了自己的SyncAdapter并在xml中正确定义了它:

这是我的sync.xml:

<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
    android:contentAuthority="com.example.tv.programs"
    android:accountType="com.example.tv.sync"
    android:supportsUploading="false"
    android:userVisible="true"
/>

android清单的相应部分,我在其中定义了我的同步服务和提供程序:

<service android:name=".sync.ProgramSynchronizationService" android:exported="true" android:process=":programs">
    <intent-filter>
        <action android:name="android.content.SyncAdapter" />
    </intent-filter>
    <meta-data
        android:name="android.content.SyncAdapter"
        android:resource="@xml/sync" />
</service>

<provider android:name="com.example.tv.providers.ProgramContentProvider" 
    android:authorities="com.example.tv.programs" />

我做错了什么吗,因为我没有在下面看到任何可见的东西数据与同步部分?

I am writing my own SyncAdapter for android devices that should synchronize TV broadcast information to the device but ran into problem of not getting the Synchronize "mydata" checkbox visible under Data & Synchronization part of the account preferences.

I have implemented my own SyncAdapter and defined it properly in the xml:

Here is my sync.xml:

<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
    android:contentAuthority="com.example.tv.programs"
    android:accountType="com.example.tv.sync"
    android:supportsUploading="false"
    android:userVisible="true"
/>

Corresponding part of android manifest, where I define my sync service and provider:

<service android:name=".sync.ProgramSynchronizationService" android:exported="true" android:process=":programs">
    <intent-filter>
        <action android:name="android.content.SyncAdapter" />
    </intent-filter>
    <meta-data
        android:name="android.content.SyncAdapter"
        android:resource="@xml/sync" />
</service>

<provider android:name="com.example.tv.providers.ProgramContentProvider" 
    android:authorities="com.example.tv.programs" />

Am I doing something wrong as I don't get anything visible under the Data & Synchronization part?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沩ん囻菔务 2024-09-16 11:11:08

除了同步适配器设置之外,您还需要调用(可能在程序启动时):

ContentResolver.setIsSyncable(account, "com.example.tv.programs", 1)

In addition to your sync-adapter setup, you also need to call (perhaps at program start):

ContentResolver.setIsSyncable(account, "com.example.tv.programs", 1)
逆光下的微笑 2024-09-16 11:11:08

要添加到此,如果您想自动启用同步,您可以执行以下操作

ContentResolver.setSyncAutomatically(account, "com.example.tv.programs",true);

To add to this, if you want to enable Syncing automatically you can do

ContentResolver.setSyncAutomatically(account, "com.example.tv.programs",true);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文