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
配合得很好。
-
到目前为止,我已经做到了
BusStation.getBus().unregister(this);
@订阅
public void receiveProgress(消息){
Log.i(“Downloader”,message.getMessage()+”);
}
OnPause中注销总线
BusStation.getBus()。取消注册(此)代码>
按钮
,在该按钮上单击DownloadService启动,该服务将下载进度发送到receiveProgress
功能downloadservice
仍在下载文件,它将不会在receiveProgress
那么如何重新链接 我假设
BusStation.getBus()
返回一个单例。但是,当你重新启动应用程序时,必须再次创建singleton,因此它不再是同一个实例
您可以使用LocalBroadcastManager来解决此问题: