Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top