Questions tagged [greenrobot-eventbus]

EventBus is an Android optimized publish/subscribe event bus that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.

EventBus is an Android optimized publish/subscribe event bus. A typical use case for Android apps is gluing Activities, Fragments, and background threads together. Conventional wiring of those elements often introduces complex and error-prone dependencies and life cycle issues. With EventBus propagating listeners through all participants (e.g. background service -> activity -> multiple fragments or helper classes) becomes deprecated. EventBus decouples event senders and receivers and thus simplifies communication between app components. Less code, better quality. And you don't need to implement a single interface!

General Usage and API:

In EventBus, subscribers implement event handling methods and register themselves to the bus. Posted events are delivered to matching event handling methods based on their event type (the Java class/interfaces implemented by the event).

Using EventBus takes four simple steps:

  1. Implement any number of event handling methods in the subscriber:

    public void onEvent(AnyEventType event) {}

  2. Register subscribers:

    eventBus.register(this);

  3. Post events to the bus:

    eventBus.post(event);

  4. Unregister subscriber:

    eventBus.unregister(this);

More info: https://github.com/greenrobot/EventBus

247 questions
0
votes
1 answer

Will EventBus.post() deliver event if configChanges occur or if activity in background?

I read documentation here but there is no clear explanation will event trigger if configChanges occur in activity or if activity in background with EventBus.getDefault().post() . Now I'm using EventBus like this: EventBus.getDefault.postSticky(new…
ar-g
  • 3,417
  • 2
  • 28
  • 39
0
votes
1 answer

Send Uri of item in ListView to Fragment using EventBus onClick

Is there a way to register an onClick event for a listView item without sending an intent through startActivity, but instead just send and event using EventBus. @Override public void onClickListener(AdapterView av,View v, int position, long…
0
votes
1 answer

ListFragment and asynctask issues android

I am trying to display a list fragment in the middle of my activity. The list fragment adapter is a custom adapter (extended from BaseAdapter) with the typical ViewHolder pattern. It is implemented correctly. I have the adapter set up with…
0
votes
1 answer

Subscriber class ...TaskAdapter has no public methods called onEvent

I am having some trouble with EventBus. Particularly when I am trying to run the application it gives me the error 10-16 22:59:38.277: E/AndroidRuntime(1175): Caused by: de.greenrobot.event. EventBusException: Subscriber class…
AnnonAshera
  • 399
  • 1
  • 4
  • 12
0
votes
1 answer

Does events in greenrobot Eventbus android gets queued?

I am receiving data from arduino due to android tablet through USB. In my main activity i have a listener which executes a function when new data arrives in USB. The issue is that the function takes a while to execute , but as soon as new data…
Manav Singhal
  • 183
  • 5
  • 22
0
votes
1 answer

Activities listening for events in EventBus

I have got an activity with the view of an object received from an async HTTP request. I am using EventBus to post an event with the object and in the activity the following method: public void onEventMainThread(MyObjectEvent event) { …
-1
votes
3 answers

How to inherent from multiple Activities with LifeCycle events and event bus support in Android Java?

I have two activities that both of then extends from a base activity. i.e. CarActivity{ } GasCarActivity extends CarActivity{ function onCreate(){ registerGasEvent() // so that onLowGasEvent() will work } function checkGas(){} …
CodingTT
  • 1,125
  • 3
  • 14
  • 23
1 2 3
16
17