在 IntentService 上执行 onPostExecute

onPostExecute on IntentService

是否有 AsyncTask 的 onPostExecute 的 IntentService 版本?我正在尝试从 IntentService 发送数据,并在 IntentService 完成后将其传送到另一个 Activity。

Is there an IntentService version of AsyncTask's onPostExecute?

不,在 onHandleIntent() 完成后主应用程序线程上没有调用任何东西,除了 onDestroy()(如果没有其他排队的命令要处理)。

I'm trying to send data from the IntentService and have it delivered into another Activity after IntentService finishes.

一个解决方案是使用 LocalBroadcastManager 或 greenrobot 的 EventBus,因为它们将允许您 post 来自后台线程的事件并由您的 UI 层拾取在主应用程序线程上。

您可以通过较低级别的机制实现类似的目的,例如 Messenger 绑定到 Handler,其中服务通过 MessengerHandler.

没有。 您可以为此发送广播。在要求的 activity.

中注册