eventBus获得双@Subscribe

时间:2018-12-21 07:07:13

标签: java android

在服务中,我发布了事件,并在我的activity中收到了两个我尝试这样做的相同事件:

@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public synchronized void onEvent(EventAddNoteAndRealize event) {

    if (eventAddNoteAndRealize == null) {
        this.eventAddNoteAndRealize = event;
        getRealizeAndNote(event);
    } else if (event != null && event != eventAddNoteAndRealize) {
        this.eventAddNoteAndRealize = event;
        getRealizeAndNote(event);
    }   
}

但我总是有eventAddNoteAndRealize null

在服务中,我像这样发布此evet:

EventBus.getDefault().post(new EventAddNoteAndRealize(noteAndRealizeDAOs));

0 个答案:

没有答案