@Retention(value=CLASS) @Target(value=METHOD) public @interface ReceiverAction
Should be used on a method that must respond to a specific action in an
EReceiver annotated class. The method name will be used as action
name unless the value() field is set.
The class MAY contain several ReceiverAction annotated methods.
The method annotated with ReceiverAction may have as parameters :
Context which will be the context given in
void onReceive(Context context, Intent intent)Intent which will be the intent given in
void onReceive(Context context, Intent intent)Parcelable or Serializable
parameters annotated with ReceiverAction.Extra which will be the
extra put in the intent. The key of this extra is the value of the annotation
ReceiverAction.Extra if set or the name of the parameter.
Example :
@EReceiver
public class MyReceiver extends BroadcastReceiver {
@ReceiverAction
void mySimpleAction(Intent intent) {
// ...
}
@ReceiverAction
void myAction(@ReceiverAction.Extra String valueString, Context context) {
// ...
}
@ReceiverAction
void anotherAction(@ReceiverAction.Extra("specialExtraName") String valueString, @ReceiverAction.Extra long valueLong) {
// ...
}
@Override
public void onReceive(Context context, Intent intent) {
// empty, will be overridden in generated subclass
}
}
Note: Since
BroadcastReceiver#onReceive is abstract, you have to add an empty
implementation. For convenience, we provide the
AbstractBroadcastReceiver class, which implements that method, so you do not
have to do in your actual class if you derive it.
EReceiver,
AbstractBroadcastReceiver| Modifier and Type | Optional Element and Description |
|---|---|
String[] |
dataSchemes
Define a set of data schemes to filter the Intent.
|
String[] |
value
Define a set of actions this method should handle.
|
public abstract String[] value
public abstract String[] dataSchemes
Copyright © 2010-2015. All Rights Reserved.