EventBus Can I use this library for Activity to Service communication ?
I have tried this in my app as follows:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EventBus.getDefault().register(this);
setContentView(R.layout.activity_music_player);
Intent serviceIntent=new Intent(MusicPlayerActivityTest.this,MusicPlayerServiceTest.class);
startService(serviceIntent);
EventBus.getDefault().post(new SetSongList(songArraList, 0));
}
@Override
protected void onDestroy() {
EventBus.getDefault().unregister(this);
super.onDestroy();
}
and in my service onEvent
called
EventBus
to communicate from a service to an activity (or vice versa). See github.com/commonsguy/cw-omnibus/tree/master/EventBus/… for an example. – Stuppy