Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在将我的应用程序从 RoboGuice 切换到 Dagger。RoboGuice 有这个不错的功能,您可以在其中注入本机组件(@Inject Context mContext 为您提供 Context 对象)。我想知道是否有人知道 Dagger 的扩展或另一个可以做到这一点的 DI 库。谢谢!
根据Dagger 问题列表上的这个线程,您可以完成此行为,但您需要通过模块注入它,如此处所述
是的,这对 Dagger 来说太容易了,所以这个功能不需要开箱即用。
此外,您可以具体控制要注入的上下文,在其范围内注入活动上下文非常有用。