Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

RoboGuice in @EBean

WonderCsabo edited this page Apr 21, 2015 · 3 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, 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);
    }

} 

Using AndroidAnnotations

Questions?

Enjoying AndroidAnnotations

Improving AndroidAnnotations

Extending AndroidAnnotations

Clone this wiki locally