我尝试在“doInBackground”中捕获,如果应用程序在“doInBackground”中执行 catch 方法,我不希望代码运行 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
}
}