Using Guice to inject dependencies into an Android activity's constructor

让人想犯罪 __ 提交于 2019-12-03 16:23:10

问题


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



来源:https://stackoverflow.com/questions/2525969/using-guice-to-inject-dependencies-into-an-android-activitys-constructor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!