org.greenrobot.eventbus.EventBusException其超类没有带@Subscribe批注的公共方法

时间:2019-05-09 16:52:41

标签: java android greenrobot-eventbus

我正在使用# Load libraries library(ggplot2) library(egg) #> Warning: package 'egg' was built under R version 3.5.3 #> Loading required package: gridExtra # Create plot p <- ggplot(mtcars, aes(mpg, wt)) p <- p + geom_point() p <- p + facet_grid(gear ~ cyl) p <- tag_facet(p) p <- p + theme(strip.text = element_text()) print(p) 控制EventBus的状态,但是在执行过程中遇到了错误。

  

由于:org.greenrobot.eventbus.EventBusException:订阅者类   maa.MainActivity及其超类没有公共方法,   @Subscribe批注

mediaplayer

RadioManager.java

 @Override
    public void onStart() {
        super.onStart();
        EventBus.getDefault().register(this);
    }

    @Override
    public void onStop() {
        EventBus.getDefault().unregister(this);
        super.onStop();
    }

    @Override
    protected void onDestroy() {
        radioManager.unbind();
        super.onDestroy();
        if (radioManager.isPlaying()) {
            radioManager.playOrPause(getPreference(getApplicationContext()));
        } else {
            radioManager.playOrPause(getPreference(getApplicationContext()));
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        radioManager.bind();
    }

    @Subscribe
    public void onEvent(String status) {
        switch (status) {
            case PlaybackStatus.LOADING:
                progressloading.setVisibility(View.VISIBLE);
                trigger.setVisibility(View.GONE);
                break;
            case PlaybackStatus.ERROR:
                Toast.makeText(this, R.string.no_stream, Toast.LENGTH_SHORT).show();
                break;
        }
        if (status.equals(PlaybackStatus.PLAYING)) {
            trigger.setVisibility(View.VISIBLE);
            progressloading.setVisibility(View.GONE);

        }
        trigger.setImageResource(status.equals(PlaybackStatus.PLAYING)
                ? R.drawable.ic_pause_black
                : R.drawable.ic_play_arrow_black);
    }

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题,我的错误是进口

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;