I am working on the ROS android project. I am implementing the EventBus to constantly updating the value for textViews. I am posting values from ManActivity to MainFragment
But I am getting below Error
org.greenrobot.eventbus.EventBusException: Subscriber class com.korechi.roamioapp.MainActivity and its super classes have no public methods with the @Subscribe annotation
I tried this link but it didn't help. And I am not using the proGuard so I don't think I need any rule to fix and not sure how proGuard works.
Thank you, any help much appreciated.
I am registering Event on MainActivity and my MainActivity extends AppCompatRosActivity
@Override
protected void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}
@Override
protected void onStop() {
super.onStop();
EventBus.getDefault().unregister(this);
}
Posting the value from MainActivity
Subscriber<Float32> speed = connectedNode.newSubscriber("/RoamIO/speed/app_ver", Float32._TYPE);
speed.addMessageListener(new MessageListener<Float32>() {
@SuppressLint("StringFormatMatches")
@Override
public void onNewMessage(Float32 float32) {
Log.d(TAG, "onNewMessage: /RoamIO/speed/app_ver : "+String.format(getResources().getString(R.string.speedMetric)));
fragmentMessages.setSpeed(String.format(getResources().getString(R.string.speedMetric)));
EventBus.getDefault().post(fragmentMessages);
// mainFragment.speedTxtView.setText(String.format(getResources().getString(R.string.speedMetric),
// float32.getData()));
}
});
subscribing from MainFragment like this
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(Messages messages){
speedTxtView.setText(messages.getSpeed());
}
Gradle
implementation 'org.greenrobot:eventbus:3.2.0'