AsyncTaskLoader基本的例子。 (安卓) [英] AsyncTaskLoader basic example. (Android)

查看:263
本文介绍了AsyncTaskLoader基本的例子。 (安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是用我的应用程序加载器,并根据其结果,我从我使用该装载机的联系人进行查询得到我进行一些计算,并将其存回一个SQLite数据库。我想这个操作是异步,但是我很困惑使用一个异步任务之间,因为我有很多不同的数据类型的返回,或者我应该用一个简单的处理程序或AsyncTaskLoader,我希望它是简单的,因为我是新来的装载机。我试着搜索周围的AsyncTaskLoader的例子​​,但似乎火箭科学,任何在我的情况的情况下三者的基本和简单的功能的例子将是一个很大的帮助。

I am using a Loader in my application and based on the result I get from the query I perform on COntacts using this Loader I perform some calculations and store them back in a Sqlite DB. I want this operation to be Asynchronous, however I am confused between using an Async task, as I have lot of different data types to return or should I use a simple handler or an AsyncTaskLoader, I want it to be simple as I am new to Loaders. I tried to search around for examples of AsyncTaskLoader but it seems rocket science, a basic and simple functional example of any of the three in the context of my scenario would be a lot helpful.

推荐答案

由于蜂窝和V4兼容库,可以使用 AsyncTaskLoader 。据我了解,在 AsyncTaskLoader 可通过配置的变化求生存像屏幕翻转。但是,使用的AsyncTask 你可以乱用的配置更改。

Since Honeycomb and the v4 Compatibility Library it is possible to use AsyncTaskLoader. From what I understand, the AsyncTaskLoader can survive through config changes like screen flips. But using AsyncTask you can mess up with configuration changes.

关键信息: AsyncTaskLoader 装载机的子类。这类执行相同的功能的AsyncTask,但好一点,它也可以是在处理配置变化(屏幕取向)是有用的。

Key information: AsyncTaskLoader is subclass of Loader. This class performs the same function as the AsyncTask, but a bit better, it can also be useful in handling configuration changes (screen orientation).

一个很好的例子,说明这里给出。 <一href="http://www.java$c$cgeeks.com/2013/01/android-loaders-versus-asynctask.html">http://www.java$c$cgeeks.com/2013/01/android-loaders-versus-asynctask.html

A very good example and explanation is given here. http://www.javacodegeeks.com/2013/01/android-loaders-versus-asynctask.html

谷歌有一个pretty的很好的例子,直接在API文档。 Android的设计模式提供了更多的细节和背后装载机的理由。

Google has a pretty good example directly in the API Docs. Android Design Patterns provides some more detail and the reasoning behind Loaders.

本教程将definetly帮助你。 <一href="http://www.java$c$cgeeks.com/2013/08/android-custom-loader-to-load-data-directly-from-sqlite-database.html">http://www.java$c$cgeeks.com/2013/08/android-custom-loader-to-load-data-directly-from-sqlite-database.html

This tutorial will definetly help You. http://www.javacodegeeks.com/2013/08/android-custom-loader-to-load-data-directly-from-sqlite-database.html

这篇关于AsyncTaskLoader基本的例子。 (安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆