greenrobot-eventbus-3.0

EventBus comunication between activity and service

有些话、适合烂在心里 提交于 2021-02-19 08:30:06
问题 I'm working on an Android application with EventBus library. I have an activity and a service. I want to to fire an event from activity and receive it on service. The activity is: public class MainActivity extends AppCompatActivity { public static final String TAG="ACTIVITY"; @Subscribe(threadMode = ThreadMode.MAIN) public void onMessageEvent(StartEvent event) { Log.d(TAG, "Received message"); Snackbar.make(fab, "Stop task", Snackbar.LENGTH_LONG).show(); txtMessage.setText(event.message); };

Is Greenrobot EventBus sticky events order guaranteed?

微笑、不失礼 提交于 2019-12-25 07:39:51
问题 I'm starting using EventBus 3.0.0. I'm having 3 sticky events to be sent from Service to Activity: action started action progress action finished i'm listening to the events on main thread: @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) public void on...Event(... event) { ... } The service sends events in order: started-progressN-..-progressM-finished and the subscribed Activity updates the UI according to the events. After the activity is rotated i expect to get sticky events in the

Eventbus onMessageEvent not getting called

蹲街弑〆低调 提交于 2019-12-11 03:35:53
问题 I have implemented EventBus in my project but I am not getting all of my events public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button = findViewById(R.id.btn); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { EventBus.getDefault().post(new MessageEvent()); EventBus.getDefault().post(new