2

Where/when should I add the index for Green Robot Event Bus library:

EventBus.builder().addIndex(new MyEventBusIndex()).installDefaultEventBus();

as described here? I've put this onCreate() method of my launcher activity, but sometimes I get:

Caused by: org.greenrobot.eventbus.h: Default instance already exists. It may be only set once before it's used the first time to ensure consistent behavior.

Where am I wrong? Many thanks.

Jumpa
  • 4,319
  • 11
  • 52
  • 100
  • I'm not sure, but you may want to put it in the constructor (without any arguments): `public MainActivity() { EventBus.builder().addIndex(new MyEventBusIndex()).installDefaultEventBus(); }` – Chaoz Mar 08 '16 at 16:07

1 Answers1

0

you can do this once in your Android Application class

see Configure the default EventBus instance in the documentation

Note: this can be done only once before the default EventBus instance is used the first time. Subsequent calls to installDefaultEventBus() will throw an exception. This ensures consistent behavior in your app. Your Application class is a good place to configure the default EventBus instance before its used.

TmTron
  • 17,012
  • 10
  • 94
  • 142