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