I’m using AIButton
in my app and I have a AsyncTask
which gets executed after AIButton is clicked and receives some command and AsyncTask sometimes
You have to do one following thing when canceling AsyncTask. on your button click method.
public void AIButtonClick(View view){
asyncTask.cancel(false);
}
and check in doInBackground if it's canceled then return from it.
@Override
protected String doInBackground(String... params) {
if(asyncTask.isCanceled()) return;
}
Also on in your onPause method you have cancel it was well.
@Override
public void onPause() {
super.onPause();
if(asyncTask!=null){
asyncTask.cancel(false);
}
}