Questions tagged [greenrobot-eventbus-3.0]

EventBus is an open-source library for Android using the publisher/subscriber pattern to solve the problem of loose coupling. EventBus enables central communication to decoupled classes with just a few lines of code – simplifying the code, removing dependencies, and speeding up app development.

EventBus: Events for Android

EventBus is an open-source library for Android using the publisher/subscriber pattern to solve the problem of loose coupling. EventBus enables central communication to decoupled classes with just a few lines of code – simplifying the code, removing dependencies, and speeding up app development. EventBus System

Benefits using EventBus: It…

  1. simplifies the communication between components
    • decouples event senders and receivers
    • performs well with Activities, Fragments, and background threads
    • avoids complex and error-prone dependencies and life cycle issues
  2. is fast; specifically optimized for high performance
  3. is tiny (<50k jar)
  4. is proven in practice by apps with 100,000,000+ installs has advanced features like delivery threads, subscriber priorities, etc.

Further EventBus Features

  • Convenient Annotation based API: Convenient Annotation based API: Simply put the @Subscribe annotation to your subscriber methods. Because of a build time indexing of annotations, EventBus does not need to do annotation reflection during your app’s run time.
  • Android main thread delivery: When interacting with the UI, EventBus can deliver events in the main thread regardless how an event was posted.
  • Background thread delivery: If your subscriber does long running tasks, EventBus can also use background threads to avoid UI blocking.
  • Event & Subscriber inheritance: In EventBus, the object oriented paradigm apply to event and subscriber classes. Let’s say event class A is the superclass of B. Posted events of type B will also be posted to subscribers interested in A. Similarly the inheritance of subscriber classes are considered.
  • Jump start: You can get started immediately – without the need to configure anything – using a default EventBus instance available from anywhere in your code.
  • Configurable: To tweak EventBus to your requirements, you can adjust its behavior using the builder pattern.
59 questions
1
vote
2 answers

Transfer data from FirebaseMessagingService to Activity using rxjava

I am currently just using EventBus to transfer data from FirebaseMessagingService onMessageReceived to MainActivity , but this is getting tricky as complexity goes on and what if i get multiple notifications ? on the other hand, Data transfer is…
1
vote
1 answer

Exception using EventBus 3.0 in Firebase Service - Android

I am trying to use Eventbus for the first time with Firebase. I am getting the next error as "Subscriber class java.lang.Class and its super classes have no public methods with the @Subscribe annotation". What am I doing…
Luiz Alves
  • 2,575
  • 4
  • 34
  • 75
1
vote
0 answers

eventbus communication between Activity and Fragment

Activity 'A' and it has a drawer fragment. I need to change the drawer fragment specific imageview based on event posting from Activity 'B'. In drawer fragment - @Override public void onStart()…
demo_Ashif
  • 195
  • 1
  • 12
1
vote
0 answers

Greenrobot EventBus sticky events priorities?

Since Greenrobot EventBus events order is not guaranteed by default is there any chance to set sticky events priorities to make the right order? I need to restore events order somehow after listener unregistered/registrered for screen rotation…
4ntoine
  • 19,816
  • 21
  • 96
  • 220
1
vote
1 answer

Subscribed Events and Polymorphism fire twice

I recently changed my app to be less dependent on other parts of the application by switching to eventbus. Now I am seeing a strange issue, I don't know if its a bug or intended feature of green robot's eventbus. Say I have an Event A and Event B,…
1
vote
1 answer

Android event bus: events fire without waiting for a post

I have a button in my app that starts a custom service class when clicked. Then, when clicked again, I stop the service and display a progress dialog. The onClick of that buttons looks like this: public void onClick(View v) { if…
0
votes
1 answer

Controlling play or pause button using eventbus

If we open our app the news fragment is loaded and the news automatically starts to play. We are using Exoplayer for playing the news. Notification is created by Exoplayer via PlayerNotificationManager. The problem is that the play pause button…
0
votes
0 answers

EventBusException: its super classes have no public methods with the @Subscribe annotation

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:…
Arpit Patel
  • 7,212
  • 5
  • 56
  • 67
0
votes
2 answers

Service (event bus subscriber) not receiving post from Activity

NotificationEvent Class (POJO) public class NotificationEvent { LoggedInUserInterface liui; public NotificationEvent(LoggedInUserInterface liui) { this.liui = liui; } } MyFirebaseMessagingService (subscriber) LoggedInUserInterface…
Dylan
  • 375
  • 1
  • 2
  • 12
0
votes
1 answer

EventBus - threadMode not regonized as @Subscribe annotation property :cannot resolve method threadMode

I am using GreenRobot EventBus , I wanted to define some Threading properties, according to docs, However, when I write: @Subscribe(threadMode = ThreadMode.MAIN) public void onShowNotification(NotificationEvent event) { if(event ==…
0
votes
1 answer

How can an AppCompatActivity communicate with FragmentActivity using the EventBus?

Question, How can an AppCompatActivity communicate with FragmentActivity using the EventBus? Findings, FragmentActivity can communicate with AppCompatActivity and the onEvent method is called, but if we switch the communication path to…
0
votes
1 answer

Unit Test EventBus on Android

I've already seen this SO question but yet it does not provide a solution to what I'm trying to do. I'm using EventBus (from greenrobot) to send messages across my app. I'd like to be able to unit-test my app to confirm that a message have been…
sebasira
  • 1,739
  • 1
  • 22
  • 41
0
votes
1 answer

How to use EventBus in two Activity on Android

In my application i want use EventBus for manage events. In my app i open activity B on the Activity A ! and i want when activity B finished, call one event in Activity A. I write below codes Activity B : private void finishWithAnimate() { …
Jungle
  • 247
  • 5
  • 16
0
votes
1 answer

I register object in parent class but subscribe events in child class, yet it still works why?

So this is exactly how I want it to work but I'm just confused on why it works. I register the object in parent class but subscribe events in child class. By registering the object in the parent class, wouldn't EventBus be seeing type parent…
0
votes
1 answer

I can't get the EventBus data in Fragment onCreateView

I want to pass a value from an activity to fragment via EventBus. I can pass the value and read with @Subscribemethod. But I can't pass the value to a variable at the beginning of onCreateView - setupGridView(mUser). I want to add the value…
Ali Özen
  • 83
  • 2
  • 10