前面在 Android RoboGuice 使用指南(1):概述 對應(yīng) Roboguice 做了簡要的介紹,之后介紹了 Google Guice 的基本用法,Roboguice 是基本 Android 和 Google Guice 開發(fā)的適用于 Android 平臺的 Dependency Injection 開發(fā)包,下圖為使用 Roboguice 開發(fā)應(yīng)用的基本框圖:
http://wiki.jikexueyuan.com/project/android-roboguice/images/13.png" alt="" />
Android 應(yīng)用程序可以直接使用 Google Guice 來為普通類進(jìn)行注入操作,而對和 Android 平臺相關(guān)的類如 Activity,Context,Service,View 等可以使用 Roboguice 進(jìn)行注入操作。
在例 Android RoboGuice 使用指南(2):第一個例子 Hello World 介紹了使用 RoboGuice 開發(fā)的步驟,原先從 Activity 派生的類一般需要改成從 RoboActivity 派生,并添加從 RoboApplication 派生的類作為 Application 應(yīng)用的 Application 類,詳細(xì)的對應(yīng)表如下:
http://wiki.jikexueyuan.com/project/android-roboguice/images/14.png" alt="" />
RoboGuice 支持的標(biāo)記如下:
此外,RoboGuice 還提供了簡單的消息 publish/subscribe 機(jī)制,以及可以支持 Dependency Injection 的 RoboThread, RoboAsyncTask ,RoboLooperThread 等,將在后面的文章詳細(xì)說明。