Android Samples 之 basicsyncadapter

来源:互联网 发布:屏幕尺寸测量软件 编辑:程序博客网 时间:2024/06/05 20:24

basicsyncadapter 

This sample demonstrates how to implement a sync adapter to fetch background data for an app that doesn't require a user-visible account type or two-way synchronization.

The sample periodically downloads the feed from the Android Developers Blog and caches the data in a content provider. At runtime, the cached feed data is displayed inside a ListView.

To learn more about creating and using sync adapters, see Transferring Data Using Sync Adapters.

Note: Sync adapters run asynchronously, so you should use them with the expectation that they transfer data regularly and efficiently, but not instantaneously. If you need to do real-time data transfer, you should do it in an AsyncTask or an IntentService.


翻译:

基础同步适配器

这个例子展示怎么样实现一个同步适配器去为App获取后台数据,该App不要求(与服务端)可见用户类型或者双向同步。

学习更多关于创建和使用同步适配器,去看看Transferring Data Using Sync Adapters【http://developer.android.com/training/sync-adapters/index.html】

Note:同步适配器是异步执行的,所以你应该在期望它可以定期地有效地但不是瞬间地传输数据时使用它。如果你想要实时地传输数据,那么你应该在中AsyncTaskIntentService完成这一任务。


对Transferring Data Using Sync Adapters【http://developer.android.com/training/sync-adapters/index.html】的翻译,请看http://www.cnblogs.com/jdneo/p/3654168.html 。大概浏览了以下,使用同步适配器框架,用到以下物件,要会用该框架,还真要细看翻译才行。

1.内容提供器ContentProvider:为本地数据定义的,同步适配器框架运行同步适配器时也会调用到,如果该App没有ContentProvider,这时同步适配器                                         会崩溃。
2验证器:同步适配器在同步数据时,设备存储会有一个账户,服务器存储端会有登录验证
3内容提供器:为app的本地数据定义了内容提供器,
4服务Service:提供一个捆绑了验证器的服务Service,这一服务提供一个Android binder对象,允许框架调用你的验证器,并且在验证器和框架间传输数据。
5元数据文件:为框架提供组件描述,将你的验证器组件等插入到同步适配器和账户框架中。
6同步适配器:封装在设备和服务器之间传输数据的任务代码
7 清单文件: 列出该应用对于Android系统来说以上那些非常重要的信息。


0 0
原创粉丝点击