我试图取消一个 RequestAsyncTask,当我调用方法取消时,后台线程不会停止,因为 isCancelled 方法永远不会被调用,我该怎么做?这是我的代码:
Request requestUpload = Request.newUploadPhotoRequest(session, imagen, requestCallback);
Bundle params = requestUpload.getParameters();
params.putString("name", "hi everyone");
requestUpload.setParameters(params);
rq = Request.executeBatchAsync(requestUpload);
progressDialog = ProgressDialog.show(getActivity(), "", "Wait please...", true, true, new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if (rq != null) {
rq.cancel(true);
}
}
});