Package dagger.android
Class AndroidInjection
java.lang.Object
dagger.android.AndroidInjection
Injects core Android types.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
inject
(android.app.Activity activity) Injectsactivity
if an associatedAndroidInjector
implementation can be found, otherwise throws anIllegalArgumentException
.static void
inject
(android.app.Fragment fragment) Injectsfragment
if an associatedAndroidInjector
implementation can be found, otherwise throws anIllegalArgumentException
.static void
inject
(android.app.Service service) Injectsservice
if an associatedAndroidInjector
implementation can be found, otherwise throws anIllegalArgumentException
.static void
inject
(android.content.BroadcastReceiver broadcastReceiver, android.content.Context context) InjectsbroadcastReceiver
if an associatedAndroidInjector
implementation can be found, otherwise throws anIllegalArgumentException
.static void
inject
(android.content.ContentProvider contentProvider) InjectscontentProvider
if an associatedAndroidInjector
implementation can be found, otherwise throws anIllegalArgumentException
.
-
Method Details
-
inject
public static void inject(android.app.Activity activity) Injectsactivity
if an associatedAndroidInjector
implementation can be found, otherwise throws anIllegalArgumentException
.- Throws:
RuntimeException
- if theApplication
doesn't implementHasAndroidInjector
.
-
inject
public static void inject(android.app.Fragment fragment) Injectsfragment
if an associatedAndroidInjector
implementation can be found, otherwise throws anIllegalArgumentException
.Uses the following algorithm to find the appropriate
AndroidInjector<Fragment>
to use to injectfragment
:- Walks the parent-fragment hierarchy to find the a fragment that implements
HasAndroidInjector
, and if none do - Uses the
fragment
'sactivity
if it implementsHasAndroidInjector
, and if not - Uses the
Application
if it implementsHasAndroidInjector
.
HasAndroidInjector
, aIllegalArgumentException
is thrown.- Throws:
IllegalArgumentException
- if no parent fragment, activity, or application implementsHasAndroidInjector
.
- Walks the parent-fragment hierarchy to find the a fragment that implements
-
inject
public static void inject(android.app.Service service) Injectsservice
if an associatedAndroidInjector
implementation can be found, otherwise throws anIllegalArgumentException
.- Throws:
RuntimeException
- if theApplication
doesn't implementHasAndroidInjector
.
-
inject
public static void inject(android.content.BroadcastReceiver broadcastReceiver, android.content.Context context) InjectsbroadcastReceiver
if an associatedAndroidInjector
implementation can be found, otherwise throws anIllegalArgumentException
.- Throws:
RuntimeException
- if theApplication
fromContext.getApplicationContext()
doesn't implementHasAndroidInjector
.
-
inject
public static void inject(android.content.ContentProvider contentProvider) InjectscontentProvider
if an associatedAndroidInjector
implementation can be found, otherwise throws anIllegalArgumentException
.- Throws:
RuntimeException
- if theApplication
doesn't implementHasAndroidInjector
.
-