@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 four parameters:
actions()
: One or several String
indicating the
actions which will spark the method. This parameter is MANDATORYdataSchemes()
: One or several String
indicating
the data schemes which should be handled.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 =WifiManager.WIFI_STATE_CHANGED_ACTION
) public void onWifiStateChanged(Intent intent); @Receiver(actions =WifiManager.WIFI_STATE_CHANGED_ACTION
, registerAt = RegisterAt.OnResumeOnPause) public void onWifiStateChangedWithoutIntent(); @Receiver(actions =Intent.ACTION_VIEW
, dataSchemes = "http") public void onHttpUrlOpened(Intent intent); @Receiver(actions =Intent.ACTION_VIEW
, dataSchemes = {"http", "https"}) public void onHttpOrHttpsUrlOpened(Intent intent); }
Modifier and Type | Required Element and Description |
---|---|
String[] |
actions
The strings indicating the actions which will spark the method.
|
Modifier and Type | Optional Element and Description |
---|---|
String[] |
dataSchemes
The strings indicating the data schemes which should be handled.
|
boolean |
local
Whether to use LocalBroadcastManager.
|
Receiver.RegisterAt |
registerAt
The event pair when the receiver should be registered/unregistered.
|
public abstract String[] actions
public abstract String[] dataSchemes
public abstract Receiver.RegisterAt registerAt
Copyright © 2010-2015. All Rights Reserved.