Methods annotated with @Subscribe
will automatically be called if you also have a @Produce
method for the same type registered.
The best way to inform new fragments of data like this is you have an @Produce
method on the activity:
@Produce public String produceCustomString() {
return "Hello, World!";
}
And then all your fragments which have @Subscribe
methods:
@Subscribe public void onCustomStringEvent(String event) {
// ...
}
When you register a fragment which has this method, Otto will call the @Produce
method on the activity to get the latest value which it will pass to the fragment's method.