public abstract class AbstractPluginSettingReceiver extends BroadcastReceiver
Abstract superclass for a plug-in setting BroadcastReceiver implementation.
The plug-in receiver lifecycle is as follows:
onReceive(android.content.Context, android.content.Intent)
is called by the Android
frameworks.
onReceive() will verify that the Intent is valid. If the Intent is invalid, the receiver
returns
immediately. If the Intent appears to be valid, then the lifecycle continues.isBundleValid(android.os.Bundle)
is called to determine whether EXTRA_BUNDLE
is valid. If the Bundle is
invalid, then the
receiver returns immediately. If the bundle is valid, then the lifecycle continues.isAsync()
is called to determine whether the remaining work should be performed on
a
background thread.firePluginSetting(android.content.Context, android.os.Bundle)
is called to trigger
the plug-in setting's action.
Implementations of this BroadcastReceiver must be registered in the Android
Manifest with an Intent filter for
ACTION_FIRE_SETTING
. The
BroadcastReceiver must be exported, enabled, and cannot have permissions
enforced on it.
BroadcastReceiver.PendingResult
Constructor and Description |
---|
AbstractPluginSettingReceiver() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
firePluginSetting(Context context,
Bundle bundle)
If
isAsync() returns true, this method will be called on a
background thread. |
protected abstract boolean |
isAsync()
Configures the receiver whether it should process the Intent in a
background thread.
|
protected abstract boolean |
isBundleValid(Bundle bundle)
Gives the plug-in receiver an opportunity to validate the Bundle, to
ensure that a malicious application isn't attempting to pass
an invalid Bundle.
|
void |
onReceive(Context context,
Intent intent) |
abortBroadcast, clearAbortBroadcast, getAbortBroadcast, getDebugUnregister, getResultCode, getResultData, getResultExtras, goAsync, isInitialStickyBroadcast, isOrderedBroadcast, peekService, setDebugUnregister, setOrderedHint, setResult, setResultCode, setResultData, setResultExtras
public final void onReceive(Context context, Intent intent)
onReceive
in class BroadcastReceiver
protected abstract boolean isBundleValid(Bundle bundle)
Gives the plug-in receiver an opportunity to validate the Bundle, to ensure that a malicious application isn't attempting to pass an invalid Bundle.
This method will be called on the BroadcastReceiver's Looper (normatively the main thread)
bundle
- The plug-in's Bundle previously returned by the edit
Activity. bundle
should not be mutated by this method.bundle
appears to be valid. false if bundle
appears to be
invalid.protected abstract boolean isAsync()
firePluginSetting(android.content.Context, android.os.Bundle)
method performs any
sort of disk IO (ContentProvider query, reading SharedPreferences, etc.).
or other work that may be slow.
Asynchronous BroadcastReceivers are not supported prior to Honeycomb, so with older platforms broadcasts will always be processed on the BroadcastReceiver's Looper (which for Manifest registered receivers will be the main thread).
protected abstract void firePluginSetting(Context context, Bundle bundle)
isAsync()
returns true, this method will be called on a
background thread. If isAsync()
returns false, this method will
be called on the main thread. Regardless of which thread this method is
called on, this method MUST return within 10 seconds per the requirements
for BroadcastReceivers.context
- BroadcastReceiver context.bundle
- The plug-in's Bundle previously returned by the edit
Activity.