我有 3 项活动A、B 和C。在活动A 中,我开始下载一个文件,从那里我转到活动 B,然后从那里 C。现在我想要显示我在活动 B 和 C中的活动 A 中开始的文件下载的进度条。
我怎样才能在android中实现这一点。如果有人有任何想法,请帮助我。欢迎所有建议。
我有 3 项活动A、B 和C。在活动A 中,我开始下载一个文件,从那里我转到活动 B,然后从那里 C。现在我想要显示我在活动 B 和 C中的活动 A 中开始的文件下载的进度条。
我怎样才能在android中实现这一点。如果有人有任何想法,请帮助我。欢迎所有建议。
I would suggest doing the download in a Service, not in a thread tied to an Activity. The service can broadcast progress updates and each activity register to receive them. Or each Activity can bind to the Service and ask for updates. There's a nice tutorial here about downloading a file with a Service.
A further advantage of this is that the download won't be orphaned if the activity is destroyed and restarted (when, for example, the user rotates the device).