質問

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?

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top