@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 =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(); @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 |
---|---|
java.lang.String[] |
actions |
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String[] |
dataSchemes |
boolean |
local |
Receiver.RegisterAt |
registerAt |
public abstract java.lang.String[] actions
public abstract java.lang.String[] dataSchemes
public abstract Receiver.RegisterAt registerAt
public abstract boolean local
Copyright © 2010-2014. All Rights Reserved.