【发布时间】:2014-09-08 16:37:59
【问题描述】:
我有一些接口,一些具体的类实现了这些接口。我在AbstractModule 类中有配置。
但我的问题是:@Inject 只能在 RoboGuice 类中工作,例如 RoboFragment、RoboActivity ...
例如:
public class Fragment extends RoboFragment {
@Inject
ICustomClass helper; // work. helper will be initialized and call successfully.
}
public class JavaNormalClass {
@Inject
ICustomClass helper; // doesn't work. NullPointerException
}
所以,我认为RoboGuice 在普通类中时不会注入自定义类,所以我应该手动调用它。 (我猜!!!)那么,如何解决我的问题?
谢谢:)
【问题讨论】:
标签: java android dependency-injection roboguice