|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectandroid.content.Context
android.content.ContextWrapper
android.app.Application
roboguice.application.RoboApplication
public class RoboApplication
This class is in charge of starting the Guice configuration. When the
getInjector()
method is called for the first time, a new Injector is
created, and the magic begins !
To add your own custom bindings, you should override this class and override
the addApplicationModules(List)
method.
You must define this class (or any subclass) as the application in your
AndroidManifest.xml file. This can be done by adding android:name="fully qualified name of your application class"
to the <application/>
tag.
For instance :
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:name="roboguice.application.RoboApplication"> [...] </application>
How to get your Application injected as well.
Field Summary | |
---|---|
protected com.google.inject.Provider<android.content.Context> |
contextProvider
|
protected ContextScope |
contextScope
|
protected EventManager |
eventManager
|
protected ExtrasListener |
extrasListener
|
protected com.google.inject.Injector |
guiceInjector
The Injector of your application. |
protected PreferenceListener |
preferenceListener
|
protected ResourceListener |
resourceListener
|
protected List<StaticTypeListener> |
staticTypeListeners
|
protected com.google.inject.Provider<android.content.Context> |
throwingContextProvider
|
protected ViewListener |
viewListener
|
Fields inherited from class android.content.Context |
---|
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, INPUT_METHOD_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MODE_APPEND, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NOTIFICATION_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, TELEPHONY_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_SERVICE, WINDOW_SERVICE |
Constructor Summary | |
---|---|
RoboApplication()
|
Method Summary | |
---|---|
protected void |
addApplicationModules(List<com.google.inject.Module> modules)
You should override this method to add your own custom bindings. |
protected boolean |
allowContextObservers()
|
protected boolean |
allowPreferenceInjection()
Returns whether or not InjectPreference will be
supported. |
protected com.google.inject.Injector |
createInjector()
Creates an Injector configured for this application. |
com.google.inject.Injector |
getInjector()
Returns the Injector of your application. |
List<StaticTypeListener> |
getStaticTypeListeners()
|
protected void |
initInstanceMembers()
Since we don't create the injector when the RoboApplication is
instantiated, but rather when getInjector is first called (lazy
initialization), the same lazy initialization is applied to this
application instance members, which are not used until the injector is
first created. |
Methods inherited from class android.app.Application |
---|
onConfigurationChanged, onCreate, onLowMemory, onTerminate |
Methods inherited from class android.content.ContextWrapper |
---|
attachBaseContext, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getFilesDir, getFileStreamPath, getMainLooper, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSystemService, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, revokeUriPermission, sendBroadcast, sendBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendStickyBroadcast, sendStickyOrderedBroadcast, setTheme, setWallpaper, setWallpaper, startActivity, startInstrumentation, startIntentSender, startService, stopService, unbindService, unregisterReceiver |
Methods inherited from class android.content.Context |
---|
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected com.google.inject.Injector guiceInjector
Injector
of your application.
protected ContextScope contextScope
protected com.google.inject.Provider<android.content.Context> throwingContextProvider
protected com.google.inject.Provider<android.content.Context> contextProvider
protected ResourceListener resourceListener
protected ViewListener viewListener
protected ExtrasListener extrasListener
protected PreferenceListener preferenceListener
protected List<StaticTypeListener> staticTypeListeners
protected EventManager eventManager
Constructor Detail |
---|
public RoboApplication()
Method Detail |
---|
public com.google.inject.Injector getInjector()
Injector
of your application. If none exists yet,
creates one by calling createInjector()
.
getInjector
in interface InjectorProvider
protected void initInstanceMembers()
RoboApplication
is
instantiated, but rather when getInjector is first called (lazy
initialization), the same lazy initialization is applied to this
application instance members, which are not used until the injector is
first created. The main advantage is that roboguice footprint is close to
zero if no RoboActivity is used when running the application.
protected com.google.inject.Injector createInjector()
Injector
configured for this application. This
Injector
will be configured with a RoboModule
, plus
any Module
you might add by overriding
addApplicationModules(List)
. createInjector()
method.
protected void addApplicationModules(List<com.google.inject.Module> modules)
Module
interface, and add them to the list of Module
given as a
parameter. The easiest way to create an Module
implementation is
to subclass AbstractAndroidModule
, which provides proxy methods
to the binder methods (enabling more readable configuration)createInjector()
.
modules
- The list of modules to which you may add your own custom
modules. Please notice that it already contains one module,
which is this.protected boolean allowPreferenceInjection()
InjectPreference
will be
supported.
It is supported by default, but applications that have no
RoboPreferenceActivity
's may want to turn this
off for a slight startup performance gain.
protected boolean allowContextObservers()
public List<StaticTypeListener> getStaticTypeListeners()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |