Package dagger.android
Class DaggerBroadcastReceiver
java.lang.Object
android.content.BroadcastReceiver
dagger.android.DaggerBroadcastReceiver
@Beta
public abstract class DaggerBroadcastReceiver
extends android.content.BroadcastReceiver
A
BroadcastReceiver
that injects its members in every call to onReceive(Context, Intent)
.
This class should only be used for BroadcastReceiver
s that are declared in an
AndroidManifest.xml
. If, instead, the BroadcastReceiver
is created in code, prefer
constructor injection.
Note: this class is not thread safe and should not be used with multiple Handler
s in calls to Context.registerReceiver(BroadcastReceiver, android.content.IntentFilter, String, android.os.Handler)
. Injection is performed on each
invocation to onReceive(Context, Intent)
which could result in inconsistent views of
injected dependencies across threads.
Subclasses should override onReceive(Context, Intent)
and call
super.onReceive(context, intent)
immediately to ensure injection is performed immediately.
-
Nested Class Summary
Nested classes/interfaces inherited from class android.content.BroadcastReceiver
android.content.BroadcastReceiver.PendingResult
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
onReceive
(android.content.Context context, android.content.Intent intent) Methods inherited from class android.content.BroadcastReceiver
abortBroadcast, clearAbortBroadcast, getAbortBroadcast, getDebugUnregister, getResultCode, getResultData, getResultExtras, getSentFromPackage, getSentFromUid, goAsync, isInitialStickyBroadcast, isOrderedBroadcast, peekService, setDebugUnregister, setOrderedHint, setResult, setResultCode, setResultData, setResultExtras
-
Constructor Details
-
DaggerBroadcastReceiver
public DaggerBroadcastReceiver()
-
-
Method Details
-
onReceive
@CallSuper public void onReceive(android.content.Context context, android.content.Intent intent) - Specified by:
onReceive
in classandroid.content.BroadcastReceiver
-