当条件不满足时,我需要取消 AsyncTask 类 UploadPhotos,并通过 Toast 通知用户。我怎样才能做到这一点?
在我的 MainActivity
private void InicializeUploadFiles()
{
if(!IsNetworkConected())
ManageConnections();
if(IsNetworkConected())
{
try {
UploadPhotos upload = new UploadPhotos(this);
upload.execute();
}
catch (Exception e){
e.printStackTrace();
}
}
}
在我的异步任务中
@Override
protected String doInBackground(Void... args)
{
response = "";
InicializeOwnCloud();
if(IsExistFiles())
SendFolders();
return response;
}