Android Otto在活动重新创建时不发送数据(OnDestroy之后)?

Android Otto在活动重新创建时不发送数据(OnDestroy之后)?,android,service,otto,Android,Service,Otto,我正在使用将事件从IntentService发送到我的活动IntentService正在从服务器下载文件并将进度发送到活动,这与otto配合得很好。 - 到目前为止,我已经做到了 在简历中注册otto BusStation.getBus().unregister(this); 已创建用于接收事件的函数 @订阅 public void receiveProgress(消息){ Log.i(“Downloader”,message.getMessage()+”); } 在OnPause中注销总线

我正在使用将
事件
IntentService
发送到我的活动
IntentService
正在从服务器下载文件并将进度发送到活动,这与
otto
配合得很好。 -

到目前为止,我已经做到了
  • 在简历中注册otto

    BusStation.getBus().unregister(this);
    
  • 已创建用于接收事件的函数

  • @订阅
    public void receiveProgress(消息){
    Log.i(“Downloader”,message.getMessage()+”);
    }

  • OnPause中注销总线

    BusStation.getBus()。取消注册(此)

  • 我有一个
    按钮
    ,在该按钮上单击DownloadService启动,该服务将下载进度发送到
    receiveProgress
    功能

  • 但当我关闭应用程序并重新启动应用程序时,如果
    downloadservice
    仍在下载文件,它将不会在
    receiveProgress

    那么如何重新链接

    我假设
    BusStation.getBus()
    返回一个单例。但是,当你重新启动应用程序时,必须再次创建singleton,因此它不再是同一个实例

    您可以使用LocalBroadcastManager来解决此问题: