Using Guice to inject dependencies into an Android

2020-06-02 07:57发布

问题:

Does anybody know of a way to use Guice to inject dependencies into the constructor of an Activity in Android? It looks like activities normally have only the default constructor so that the platform can easily create a new instance. While it is easy enough to have a singleton to reference the injector and get dependencies that way it is less clean and introduces a bit of static state.

Any suggestions?

回答1:

I don't know how I missed this!

https://github.com/roboguice/roboguice