I have an app where I connect to a web service to retrieve data. I'm using AsyncTask to do this. Here is a piece of the code I'm using in doInBackground:
publishProgress(user.dbsCode() + ": Retrieving Standard Comments");
if (!_sync.isCancelled()) {
result = _dbFiller.fillStandardCommentsTable();
} else {
return null;
}
When I test this in my emulator it seems to work fine. isCancelled gets set & onCancelled() is called. When I test using my Galaxy Tablet (running 3.2... my project was created using 2.2), it's hit or miss if isCancelled ever gets set.
This process can take a while depending on how much data a particular user is downloading. First thing I do is download a list (of what we call) "jobs" for the user. I then call separate web services to download the different pieces for a "job". Each step includes the above code where I'm checking if my sync task is cancelled. I'm really lost. Any helpful comments are appreciated. Even just a direction. I've done so much reading about AsyncTasks that my head is spinning.