I'm developing an Android app and using Roboguice 2.0.
All has gone incrediblby well, except now. I'm trying to inject my custom bindings to a service like this and it's not working.
@Inject
private TicketService ticketService;
@Inject
private PerformanceService performanceService;
They've binded like this (first is custom app context):
RoboGuice.setBaseApplicationInjector(
this,
RoboGuice.DEFAULT_STAGE,
Modules.override(RoboGuice.newDefaultRoboModule(this))
.with(
new KoliseoModule(),
new DatastoreModule(this),
new ServiceModule()
));
public class ServiceModule extends AbstractModule {
@Override
protected void configure() {
bind(JsonCheckinTimestampService.class).to(JsonCheckinTimestampServiceImpl.class);
bind(PerformanceService.class).to(PerformanceServiceImpl.class);
bind(ShowService.class).to(ShowServiceImpl.class);
bind(TicketService.class).to(TicketServiceImpl.class);
bind(ValidationStatisticsService.class).to(ValidationStatisticsServiceImpl.class);
}
}
Any ideas?
Thanks
It's very probably and probably even garanteed that the Application subclass of an application is loaded & instantiated before the rest of the instances are created so you could try that. Create a "MyApplication extends Application" class and do your setup in its "onCreate()", don't forget to declare in your manifest.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.