I'm trying to use the Guava eventbus in Android but it my subscribed event doesn't seem to work... What am I doing wrong?
This is my activity:
package test.eventbus;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class EventBusTestActivity extends Activity {
EventBus eventbus = new EventBus();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
eventbus.register(this);
eventbus.post("message");
}
@Subscribe
void testEvent(Object bla) {
Log.d("EventBus Event", bla.toString());
}
}
Subscribe functions need to be public to work. Oops
@Subscribe
public void testEvent(Object bla) {
Log.d("EventBus Event", bla.toString());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With