forked from androidannotations/androidannotations
-
Notifications
You must be signed in to change notification settings - Fork 0
RoboGuice in @EBean
pyricau edited this page Mar 9, 2012
·
2 revisions
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, at least until RoboGuice 2.0 becomes stable, 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);
}
} 03/30/2012 The 2.5.1 release is out
- Get started!
- Cookbook, full of recipes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue