In my application I use RoboGuice for Dependency Injection. In my RoboActivities the injection works fine. If I want to inject something in a POJO like:
public class EventController {
@Inject
UserController userController;
@Inject
public EventController() {}
public void doSomethingWithUserController {
//userController is null here
userController.doSomething();
}
}
Doing it like this my userController is null. What do I have to do to inject the UserController into this POJO?
Thanks in advance!
You have to call this
RoboGuice.getInjector(Context).injectMembers(this);
in your constructor of EventController. And remove the @Inject Annotation from your constructor.