可以使用postSticky发送:
EventUtil.postSticky(ChannelWarningAbuseEvent(a,b))//抛出事件
在接收消息的方法中:
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)//接收事件
fun onChannelWarningAbuseEvent(event: ChannelWarningAbuseEvent){
EventBus.getDefault().removeStickyEvent(event)
TODO:接收消息时你需要做的
}
这样,postSticky可以在activity被进程杀死的时候,仍然保留消息,直到被接收。
注意:在接收到消息的时候,记得removeStickyEvent,防止重复接收消息。