We know that asyncTask class has four override methods and three methods runs in main ui thread but one method doInBackground runs in background thread. In case if we want to stop this background service based on same condition then we can use this logic to stop background service in between of progress like this :
protected Object doInBackground(Object... x) {
while (/* condition */) {
// work...
if (isCancelled()) break;
}
return null;}
0 Comment(s)