Tag: android contentprovider android syncadapter

没有ContentProvider的SyncAdapter

我想为我想与服务器同步的内容实现SyncAdapter。 似乎这样做,您需要为您在SyncAdapter XML属性文件中指定的权限注册ContentProvider。 由于我不希望这些内容能被手机的其他部分访问,所以我还没有实现我自己的ContentProvider,并使用个人实现来存储这些内容。 你知道是否有可能使用SyncAdapter提供同步而不提供ContentProvider? 非常感谢你。

我如何使用Android SyncAdapter?

我尝试了解Android同步逻辑。 我不明白的是Android SDK示例项目SampleSyncAdapter包含的文件SampleSyncAdapter 。 如果您下载了SDK示例,它应该位于以下文件夹中: SDK/android-sdk-PLATFORM/samples/android-VERSION/SampleSyncAdapter/res/xml/syncadapter.xml 我读过,内容提供者的权威应该是一个string或对资源的引用。 什么是内容权威, com.android.contacts在哪里? 这里是文件的内容(没有许可证信息和评论,API级别16)。 <sync-adapter xmlns:android="http://schemas.android.com/apk/res/android" android:contentAuthority="com.android.contacts" android:accountType="com.example.android.samplesync" android:supportsUploading="false" android:userVisible="true" />

为什么ContentResolver.requestSync不会触发同步?

我尝试实现Content-Provider-Sync Adapter模式,如Google IO-幻灯片26中讨论的。我的内容提供者正在工作,当我从Dev Tools Sync Tester应用程序中触发它时,我的同步工作正常,但是当我调用ContentResolver时。请求同步(帐户,权限,捆绑)从我的ContentProvider,我的同步永远不会触发。 ContentResolver.requestSync( account, AUTHORITY, new Bundle()); 编辑 – 添加清单片段我的清单xml包含: <service android:name=".sync.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包含: <?xml version="1.0" encoding="utf-8"?> <sync-adapter xmlns:android="http://schemas.android.com/apk/res/android" android:contentAuthority="AUTHORITY" android:accountType="myaccounttype" android:supportsUploading="true" /> 不知道其他代码会有用。 传递给requestSync的帐户是“myaccounttype”,传递给该调用的AUTHORITY与我的syc适配器xml匹配。 ContentResolver.requestSync是请求同步的正确方法吗? 它看起来像同步testing仪工具直接绑定到服务和调用开始同步,但是这似乎失败了与同步体系结构集成的目的。 如果这是请求同步的正确方法,那么为什么同步testing工作,但不是我对ContentResolver.requestSync的调用? 有什么我需要通过捆绑? 我正在模拟器上运行2.1和2.2的设备上进行testing。