Motheus
Motheus

Reputation: 543

It's not possible to produce and subscribe to events using Otto?

I'm trying to Subscribe and Post from the same fragment, but I'm getting this error when i try to register the fragment:

...(my method) has @Produce annotation but requires 1 arguments.  Methods must require zero arguments.

on

 BusProvider.getInstance().register(this);

So i guess it's not possible, but maybe there is an alternative without additional interfaces.

Thanks in advance!

Upvotes: 1

Views: 1173

Answers (1)

laalto
laalto

Reputation: 152807

Methods annotated with @Produce must not take any arguments. They should just return the event object.

"I'm trying to Subscribe and Post" suggests you probably need to change it to @Subscribe annotation instead.

For posting events, just use post(). @Produce is meant for returning the latest value of an event.

Upvotes: 4

Related Questions