How to cancel AsyncTask
I found great solution to solve the AsyncTask cancel problem found this so annoying to solve but it fixed the cancelation problem of AsyncTask of mine so sharing with you guys when i was using Android emulator and running Oreo version on it and trying asyncTaskObj.cancle(true); it was perfectly working i.e it was perfectly calling onCancelled() method of AsyncTask but problem arise when i tried to run it in my Marshmallow version android device, it was not calling onCancelled() method of AsyncTask so i found a solution where we call asyncTaskObj.cancle(true); i.e. in onClick event we can do version check and if version is smaller then Oreo then manually call onCancelled() method and also check if isCancelled() is true i.e. Eg: mButtonCancel.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { //set state of cancel for AsyncTask myAsyncTask .cancel( true ); //checking if v...