如何防止异步任务在单击后退按钮时取消并同时在 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请为进度条设置cancelable(false)
cancelable false 表示您无法取消(关闭)进度对话框
please setcancelable(false) to the progressbar
cancelable false means you can't cancel (dismiss) the progress dialog