在一個(gè)Activity中注冊(cè)EventBus.getDefault().register(this)出現(xiàn)以下錯(cuò)誤:
Caused by: org.greenrobot.eventbus.EventBusException: Subscriber class *** and its super classes have no public methods with the @Subscribe annotation
出現(xiàn)這個(gè)異常有兩種情況:
1、就是網(wǎng)上大多數(shù)的情況,在接收EventBus消息的方法必須是public的,還有必須注釋@Subscribe(threadMode = ThreadMode.MAIN)ps:線程自己選擇
2、我今天遇到一個(gè)情況是在注冊(cè)EventBus.getDefault().register(this)的類中沒有寫接收消息的方法,也會(huì)提示這個(gè)錯(cuò)誤。
總結(jié):在注冊(cè)EventBus.getDefault().register(this)的類中,必須要有接收的地方,而且要符合規(guī)范的書寫。