RoboGuice in @EBean - shiraji/androidannotations GitHub Wiki
Since AndroidAnnotations 2.4
Suppose you have an @EBean
component, and you would like to inject some of its members with RoboGuice.
Activities with @EActivity
allow RoboGuice injection thanks to the @RoboGuice
annotation. But we implemented the support for RoboGuice long before implementing @EBean
, so RoboGuice support is only for activities right now. We don't want to put too much effort in RoboGuice for now, because it will probably change the whole implementation.
This doesn't mean you can't use RoboGuice in your @EBean
classes, you just need to require manual injection from Guice, quite in the same way it's done in RoboActivity.
Here is an example:
@EBean
public class MyBean {
@App
MyRoboApplication application;
@Inject
SomeClass myRoboGuiceDependency;
@AfterInject
void injectRoboGuiceDependencies() {
application.getInjector().injectMembers(this);
}
}