@Retention(value=CLASS) @Target(value=METHOD) public @interface Receiver
This annotation is intended to be used on methods of an EActivity
, EFragment
or EService
.
When this annotation is used, a BroadcastReceiver
will be created to receive the Intent corresponding to the given actions
and it will call the annotated method.
The annotated method MUST return void and MAY have one parameter:
Intent
The annotation has three parameters:
actions()
: One or several String
indicating the actions which will spark the method.
This parameter is MANDATORY
registerAt()
: The moment when the BroadcastReceiver
will be registered and unregistered. By default : OnCreate/OnDestroy.
The available values depend on the enclosing enhanced component.
local()
: Specify whether android.support.v4.content.LocalBroadcastManager should be used.
To use android.support.v4.content.LocalBroadcastManager, you MUST have android support-v4 in your classpath.
Default value is false.
Example :@EActivity public class MyActivity { @Receiver(actions={android.net.wifi.WifiManager#WIFI_STATE_CHANGED_ACTION
}) public void onWifiStateChanged(Intent intent); @Receiver(actions={android.net.wifi.WifiManager#WIFI_STATE_CHANGED_ACTION
}, registerAt=RegisterAt.OnResumeOnPause} public void onWifiStateChangedWithoutIntent(); }
Modifier and Type | Required Element and Description |
---|---|
String[] |
actions |
Modifier and Type | Optional Element and Description |
---|---|
boolean |
local |
Receiver.RegisterAt |
registerAt |
public abstract String[] actions
public abstract Receiver.RegisterAt registerAt
public abstract boolean local
Copyright © 2010-2014. All Rights Reserved.