I have implemented AsyncTask in my one of activity:
performBackgroundTask asyncTask = new performBackgroundTask(); asyncTask.execute();
N
Just check isCancelled() once in a while:
isCancelled()
protected Object doInBackground(Object... x) { while (/* condition */) { // work... if (isCancelled()) break; } return null; }