我有一個嘗試和趕上「doInBackground」,我不會運行代碼運行onPostExecute如果應用程序在「doInBackground」執行catch方法。代碼如下:asynctask取消onpostexecute
public class DownloadFileAsync extends AsyncTask<String, Integer, Void> {
@Override
protected void onPreExecute(){
super.onPreExecute();
}
@Override
protected Void doInBackground(String... aurl) {
try{
//some code, jump to onPostexecute after complete
}
catch{
//some code, don't do onPostExecute after complete
}
return null;
}
@Override
protected void onProgressUpdate(Integer... progress) {
//some code
}
@Override
protected void onPostExecute(Void unused) {
//some code
}
}
THX,它爲我工作:) – melvintcs