三个参数,四个步骤
参数:
Params, 需要处理的参数,例:访问网络,需要网址,所以用String类型Progress, 进度刻度 intergResult, 处理完返回的类型
如果不需要就传空例:
privateclassMyTaskextendsAsyncTask<Void,Void,Void>{...}
四个步骤
onPreExecute(), 异步任务执行之前执行 for instance by showing a progress bar in the user interface.doInBackground(Params...), 在onPreExecute()方法执行完后立即执行.是一个后台的一个耗时操作, 处理第一个参数,第一个参数是 asynchronous task 的第一个参数. 返回结果传给最后一步onPostExecute(Result). 如果需要刻度,需要在该方法中用publishProgress(Progress...)方法把刻度值发布到These values are published on the UI thread, in theonProgressUpdate(Progress...)step.onProgressUpdate(Progress...), 更新进度条onPostExecute(Result), 在后台执行完毕把结果返回给 UI thread