Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back button closes progress dialog, doesn't cancel task #40

Open
gradha opened this issue Jun 11, 2011 · 3 comments
Open

Back button closes progress dialog, doesn't cancel task #40

gradha opened this issue Jun 11, 2011 · 3 comments

Comments

@gradha
Copy link

gradha commented Jun 11, 2011

I'm using the BetterAsyncTask with a progress dialog, and when the user presses the back button on the device the progress dialog is dismissed but the task continues running. I've managed to override this implementing the onCreateDialog() method on my activity and attaching there an OnCancelListener, but still it doesn't look too god, because I'm using globals to communicate with the task.

It would be better if the cancel listener flagged the task as cancelled and the task itself could check for this with the isCancelled() method.

@mttkay
Copy link
Owner

mttkay commented Jun 17, 2011

just know that cancel() will just set a flag which does the following:

  • if the task has not been started, it won't ever start
  • if it's running, it will keep running until it's done (i.e. it will NOT be interrupted), but not post back its result to onPostExecute
  • if it's completed, it's a no-op

in other words, it's not particularly useful if what you want to do is actually abort a long running operation.

@Aman-Aalam
Copy link

For example, If that long running task is a network activity, wouldn't aborting that long running task save the network bandwidth, which is perhaps actually what the user might have wished when he/she pressed back button to cancel the "progress" ?

@gradha
Copy link
Author

gradha commented Jun 18, 2011

The problem I have is that the OnCancelListener doesn't have access to the BetterAsyncTask, so I can't call it's cancel method. I would, but other than using a global for it I don't know how to do it.

@gradha gradha closed this as completed Jun 18, 2011
@gradha gradha reopened this Jun 18, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants