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

Greenrobot Eventbus holds variables

I have problem with Eventbus with following symptoms. I have activity which starts another activity. There is used Eventbus and boolean value set. This value is changed during activity run. For first run is all ok, but in second run, I got bad value…
Darius Radius
  • 169
  • 3
  • 14
0
votes
1 answer

How to cancel delivery of sticky message once delivered (GreenRobot-EventBus)

I am posting a sticky event from an Activity, lets call this activity A. I successfully receive this event in Activity B. I go to Activity C and again come back to activity B as I come back the receive the same event which I received earlier. I…
iZBasit
  • 1,314
  • 1
  • 15
  • 30
0
votes
1 answer

GreenRobot EventBus

Does anyone have an example of using the EventBusBuilder for greenrobot's Eventbus? I have an app that is using EventBus.getDefault() all over the place, but now I want to configure that bus to stop sending the no subscriber message. It is…
JuddGledhill
  • 149
  • 1
  • 1
  • 11
0
votes
1 answer

Unable to get update GreenRobot EventBus subscription inside Fragment

Inside my activity am posting the GreenRobot Event . Inside fragment i register like EventBus.getDefault().register(this); But unable to automatically fired the subscription side fragment. is it possible to get updated inside fragment if yes any…
0
votes
1 answer

Unexpected behavior of same methods in different threads

My initial question was: Android GraphView project get freeze with real time updates. In this one I was asking about possible concurrency in UI thread of 3 plots. On memory allocation plot it looks like this: I was receiving data directly from my…
sebap123
  • 2,541
  • 6
  • 45
  • 81
0
votes
1 answer

EventBus Response inside IntentService

On implementing onHandleIntent(Intent inte) of IntentService Class,i need to call a webservice which is added in another class say "Webservices.Class".Through EventBus.getDefault().post(new ResponseEvent()),it is delivering response in all…
KP_
  • 1,854
  • 25
  • 43
0
votes
1 answer

Subscriber class android.app.Application has no public methods called onEvent

I have delegated some of my Views from Activity to a class named BottomBar. What I want is when I the back button to send an event to the BottomBar so an animation starts to play. @Override public void onBackPressed() { if (isSubMenuDisplayed)…
vicolored
  • 815
  • 2
  • 10
  • 20
0
votes
2 answers

Using same fragment across the tabs in PageSlidingTabStrip: Wrong Views are returning

I have 8 tabs. As all the tabs should display the custom list, i am trying to add the same Fragment instance. I am downloading the list using EventBus in OnEventBackGroundThread and adding it to adapter in OnEventMainThread. I can see the…
0
votes
1 answer

How to prevent calling all 'onEvent' methods in class hierarchy

I am struggling with preventing call all methods in class hierarchy chain. Lets say i have a base class: class BaseModel { /* Some basic fields goes here */ } class ModelCompany extends BaseModel { /* Fields goes here */ } Then I want to post…
user2930040
0
votes
1 answer

Android: How to update ListView when user Scrolls down to bottom using eventBus and arrayadapter

Initially the listView has 20 items. I need to update the listView with next 20 items when user scrolls down all the way to the bottom. I am using ArrayAdapter to achieve this. The items in the listView are getting from the REST API which takes…
0
votes
1 answer

Communicate from background thread to main via Greenrobot Eventbus

In my app I use SyncAdapter(AbstractThreadedSyncAdapter) for synchronisation with server. Basically in background service I insert data to sql table, then on finish I want to inform UI to update ListView with new data. For this matter I tried to use…
Rafael
  • 6,091
  • 5
  • 54
  • 79
0
votes
3 answers

Android Lifecycle and Eventbus Issues

I am having a few issues with the android lifecycle and Eventbus. https://github.com/greenrobot/EventBus Currently, I am registering the activity to the bus in the onCreate lifecycle callback. I am also unregistering it at the onStop callback. And…
AnnonAshera
  • 399
  • 1
  • 4
  • 12
0
votes
1 answer

How to get the parameter from the event when using Rxjava as an EventBus

I'm accepting a json from the network, in a service. It notifies an RxBus of the event: try { String m = msg.getData().getString("message"); Log.i("handleMessage", m); JSONObject message1 = (JSONObject) new…
sirvon
  • 2,547
  • 1
  • 31
  • 55
0
votes
1 answer

Android Service for communicating with server

I need the service to have a steady connection with the server. Activity and service should have bi-directional communication. Here are the options I know Use intent service Extend Service class ( make it run in a different process ) and…
0
votes
1 answer

EventBus Post or postSticky from AbstractThreadedSyncAdapter to Activity

I've googled for a while now, read the docs but I couldn't find any answer. My [simplified] scenario is: The user first logs-in to the app, a sync request is fired, my onPerformSync gets called. I'm trying to post events through EventBus from…
Leonardo
  • 3,141
  • 3
  • 31
  • 60
1 2 3
16
17