如何在android中启用自定义帐户同步?
我正在为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除了同步适配器设置之外,您还需要调用(可能在程序启动时):
In addition to your sync-adapter setup, you also need to call (perhaps at program start):
要添加到此,如果您想自动启用同步,您可以执行以下操作
To add to this, if you want to enable Syncing automatically you can do