I would like to stop my asynchronous thread on back click of user.
Could you please suggest if there is any way to stop asynchronous thread in android.
Please forward your suggestions.
I would like to stop my asynchronous thread on back click of user. Could
Share
If you’re talking about
AsyncTaskthen you can call itscancel()method. If you passtrueto this method and the task is waiting on some object or I/O operation then the waiting will be interrupted and the task will be cancelled. But if you passfalseto this method or the task is not waiting (e.g. performing some calculations) then it will not be cancelled. In this case you can callisCancelled()method fromdoInBackground()and finish calculations whenisCancelled()returnstrue.