使用吉斯注入依赖成一个Android活动的构造 [英] Using Guice to inject dependencies into an Android activity's constructor

查看:102
本文介绍了使用吉斯注入依赖成一个Android活动的构造的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道的方式来使用吉斯注入依赖到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

这篇关于使用吉斯注入依赖成一个Android活动的构造的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆