如何防止异步任务在单击后退按钮时取消并同时在 android 中显示上一个活动

发布于 2024-12-29 18:27:13 字数 167 浏览 2 评论 0原文

我正在使用异步任务下载音频文件,并且有一个单独的按钮用于取消此下载(即取消异步任务)。我需要的是,一旦按下后退按钮,异步任务就不能完成,但同时必须打开前一个活动。

通常发生的情况是,当按下后退按钮时,进度对话框就会消失。我想做的是进度对话框不能被取消,同时必须显示下一个活动。有什么办法可以实现这一点吗?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以酷 2025-01-05 18:27:13

请为进度条设置cancelable(false)
cancelable false 表示您无法取消(关闭)进度对话框

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文