roy mathew
roy mathew

Reputation: 7800

how to prevent an async task from cancelling on back button click and at the same time display the previous activity in android

I am using async task for downloading an audio file and I am having a separate button for canceling this downloading (i.e. for cancelling the async task). What I need is, as soon as the back button is pressed the async task must not be finished, but at the same time, the previous activity must be opened.

What is usually happening is that when ever back button is pressed the progress dialog vanishes. What I am trying to do is that the progress dialog must not get canceled and at the same time next activity must be displayed. Is there any way for achieving this?

Upvotes: 1

Views: 501

Answers (1)

Ramesh Solanki
Ramesh Solanki

Reputation: 2926

please setcancelable(false) to the progressbar cancelable false means you can't cancel (dismiss) the progress dialog

Upvotes: 2

Related Questions