Question

How can I create a singleton that gets injected with an application context. Just annotating with @Singleton and then using @Inject on the constructor ends up generating an UnscopedProvider class that will not compile. How can I make an ApplicationScoped provider... or is there another mechanism to accomplish this?

Était-ce utile?

La solution

The solution I ended on here is to create an init(Application app) {} method on the Singleton, then inject the Singleton into my @Application annotated class and call the init method using the Application that's injected into that class. I think this is the only way to do this currently.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top