Android 和依赖注入 [英] Android and Dependency Injection

查看:20
本文介绍了Android 和依赖注入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找有关在 Android 开发中使用依赖项注入容器的一些信息,但徒劳无功.具体来说,如何覆盖 Activity 的创建,这种方式在从被杀死(无论出于何种原因)回来时也能正常工作.

I've been looking around, in vain, for some information on using a dependency injection container in Android development. Specifically, how to override the creation of an Activity in a way that will also work when coming back from being killed (for whatever reason).

有人有这方面的经验吗?

Has anyone got any experience in this area?

推荐答案

看来你可以使用 Google Guice 2.0 与 Android.您还可以查看 roboguice.

It appears you can use Google Guice 2.0 with Android. You might also look into roboguice.

Spring 现在也可用于 Android

Roboguice 现在已被弃用.您可以尝试 Toothpick,正如 Toothpick 背后的开发人员在评论中提到的那样.

Roboguice is now deprecated. You might try Toothpick as mentioned in the comments by the developer behind Toothpick.

这篇关于Android 和依赖注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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