资源简介
Rules::
- The AsyncTask instance must be created in UI thread.
- .execute must be invoked on the UI thread.
- Never call objMyTask.onPreExecute(), objMyTask.doInBackground(), objMyTask.onProgressUpdate(), objMyTask.onPostExecute manually.
- The AsyncTask can be executed only once (an exception will be thrown if a second execution is attempted.)
AsyncTask have Four Main Method...
- onPreExecute()
- doInBackground()
- onProgressUpdate()
- onPostExecute()
- onPreExecute-This method is called first when you start AsyncTask using objAsync.execute().And mostly this method is use for initializing dialog(ProgressDialog,CustomDialog) and showing.
- doInBackground-The main purpose of AsyncTask is accomplished by this method.Any non-UI thread process is running in this method.Such as Rss Feed Reader,Image and video Uploading and Downloading.You cant handle your View in this method.Because this method is non-UI thread.While any background process is running if you want to handle UI therea are onProgressUpdate method. after completion of process this method send result to OnPostExecute.
- onProgressUpdate-While backgrounding task is running ,you can handle your UI using this method .Such as status of downloading or uploading task.and this method is called from doInBackground.Using publishProgress() you can call onProgressUpdate method to update UI while process is running.
- onPostExecute -This method is called after the background computation finishes.The result of background process in passed in this method as parameters.And now you can dismiss progress dialog ,to indicate that background task is completed.
You can cancel AsyncTask using objAsyncTask.cancel().then you just check in doInBackground,
if (isCancelled()) {
break;
} else {
//continue...
}
See this Image For more Clear.
代码片段和文件信息
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.samir;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int btncancel=0x7f050003;
public static final int btnstart=0x7f050000;
public static final int progressBar1=0x7f050002;
public static final int tv1=0x7f050001;
public static final int tvper=0x7f050004;
}
public static final class layout {
public static final int main=0x7f030000;
public
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 364 2012-05-29 11:25 Android AsyncTask\.classpath
文件 853 2012-05-29 11:25 Android AsyncTask\.project
文件 725 2012-05-29 11:50 Android AsyncTask\AndroidManifest.xm
目录 0 2012-05-29 12:19 Android AsyncTask\assets
文件 17430 2012-05-29 12:09 Android AsyncTask\bin\Android AsyncTask.apk
文件 969 2012-05-29 12:12 Android AsyncTask\bin\classes\com\samir\MainActivity$1.class
文件 1031 2012-05-29 12:12 Android AsyncTask\bin\classes\com\samir\MainActivity$MyTask$1.class
文件 920 2012-05-29 12:12 Android AsyncTask\bin\classes\com\samir\MainActivity$MyTask$2.class
文件 4239 2012-05-29 12:12 Android AsyncTask\bin\classes\com\samir\MainActivity$MyTask.class
文件 1093 2012-05-29 12:12 Android AsyncTask\bin\classes\com\samir\MainActivity.class
文件 313 2012-05-29 12:07 Android AsyncTask\bin\classes\com\samir\R$attr.class
文件 380 2012-05-29 12:07 Android AsyncTask\bin\classes\com\samir\R$drawable.class
文件 484 2012-05-29 12:07 Android AsyncTask\bin\classes\com\samir\R$id.class
文件 405 2012-05-29 12:07 Android AsyncTask\bin\classes\com\samir\R$layout.class
文件 400 2012-05-29 12:07 Android AsyncTask\bin\classes\com\samir\R$string.class
文件 468 2012-05-29 12:07 Android AsyncTask\bin\classes\com\samir\R.class
目录 0 2012-05-29 12:19 Android AsyncTask\bin\classes\com\samir
目录 0 2012-05-29 12:19 Android AsyncTask\bin\classes\com
目录 0 2012-05-29 12:19 Android AsyncTask\bin\classes
文件 6836 2012-05-29 12:08 Android AsyncTask\bin\classes.dex
文件 3966 2012-05-29 11:41 Android AsyncTask\bin\res\drawable-hdpi\ic_launcher.png
目录 0 2012-05-29 12:19 Android AsyncTask\bin\res\drawable-hdpi
文件 1537 2012-05-29 11:41 Android AsyncTask\bin\res\drawable-ldpi\ic_launcher.png
目录 0 2012-05-29 12:19 Android AsyncTask\bin\res\drawable-ldpi
文件 2200 2012-05-29 11:41 Android AsyncTask\bin\res\drawable-mdpi\ic_launcher.png
目录 0 2012-05-29 12:19 Android AsyncTask\bin\res\drawable-mdpi
目录 0 2012-05-29 12:19 Android AsyncTask\bin\res
文件 11781 2012-05-29 12:09 Android AsyncTask\bin\resources.ap_
目录 0 2012-05-29 12:19 Android AsyncTask\bin
文件 1008 2012-05-29 12:07 Android AsyncTask\gen\com\samir\R.java
............此处省略25个文件信息
- 上一篇:android 解析 Rss xm
l - 下一篇:android 多选菜单
相关资源
- android 多选菜单
-
android 解析 Rss xm
l - android 猜名字 有奖 完整源码
- android 滑动滚屏的实现
- Android ExpandableList 列表
- Android 图形图表
- android 照片拍摄 录音等功能
- Android滑动式菜单
- 乱码
- 简单转盘实现
- android 自绘switchButton
- android 上传
- Android用Intent实现Video 视频功能
- Android用Intent实现Camera 拍照功能
- 讀取簡訊
- android 异步加载资源
-
android 中 ja
vasc ript 与java 交互 - miniTwitter登录界面
- android notification 通知
- android TextView、EditText和ImageView代码
- android VideoCamera 摄像机
- android Sax解析
- android 从外部程序获得ContentProvider提供
- android SharedPreferences储存类型
- android AppWidgetExample(AppWidget)源码
- android TabActivityExample(TabActivity)
- android broadcast (广播生命周期)
- android 创建/删除快捷方式
- android SeeJoPlay播放器
- 一种类似于Excel表格(网上找的,感觉
评论
共有 条评论