使用吉斯注入依赖成一个Android活动的构造吉斯、Android

2023-09-05 02:18:13 作者:绊人心i

有谁知道的方式来使用吉斯注入依赖到Android中的活动的构造?它看起来像活动通常只有默认的构造函数,这样的平台可以轻松地创建一个新的实例。虽然这是很容易有一个单引用的注射器,并获得依赖这种方式是不太干净,并介绍了一下静止状态。

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.

有什么建议?

推荐答案

我不知道我怎么错过了!

I don't know how I missed this!

https://github.com/roboguice/roboguice