异步任务开始,在不同的活动结束不同、任务、结束

2023-09-12 05:45:09 作者:学会抛开过去

我想实现以下行为,但我不知道如何:

I would like to achieve the following behaviour, but I'm not sure how:

在用户启动的活动 在活动开始的AsyncTask的 在用户执行创建一个新的活动有一定作用 的AsyncTask的完成并以某种方式将结果返回到新的活动

有没有实现这种行为的一种方式?

Is there a way of achieving this behaviour?

感谢您

推荐答案

创建服务的是本身派生自己的线程和做你的后台处理。您可以绑定您的活动,该服务让您可以回调到一个活动时,你的处理完成。

Create a Service that itself spawns its own thread and does your background processing. You can bind your activities to the service so you can call back into an activity when your processing is complete.