在一个AsyncTask的
in a AsyncTask
在那里去的返回值
保护布尔doInBackground(整数... PARAMS)
通常我们开始AsyncTask的使用
新AsyncTaskClassName()执行(参数1,参数2 ......);
不返回任何值
usually we start AsyncTask with
new AsyncTaskClassName().execute(param1,param2......);
which doesn't return any value
该值就可以在onPostExecute您可能希望以致使工作覆盖。
The value is then available in onPostExecute which you may want to override in order to work with the result.
下面是来自谷歌的文档例如code片断:
Here is example code snippet from Google's docs:
private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
protected Long doInBackground(URL... urls) {
int count = urls.length;
long totalSize = 0;
for (int i = 0; i < count; i++) {
totalSize += Downloader.downloadFile(urls[i]);
publishProgress((int) ((i / (float) count) * 100));
}
return totalSize;
}
protected void onProgressUpdate(Integer... progress) {
setProgressPercent(progress[0]);
}
protected void onPostExecute(Long result) {
showDialog("Downloaded " + result + " bytes");
}
}