|
15 | 15 | */ |
16 | 16 | package org.androidannotations.annotations; |
17 | 17 |
|
18 | | - |
19 | 18 | import java.lang.annotation.ElementType; |
20 | 19 | import java.lang.annotation.Retention; |
21 | 20 | import java.lang.annotation.RetentionPolicy; |
22 | 21 | import java.lang.annotation.Target; |
23 | 22 |
|
24 | 23 | /** |
25 | 24 | * <p> |
26 | | - * This annotation is intended to be used on methods of an {@link EActivity}, {@link EFragment} or {@link EService}. |
27 | | - * When this annotation is used, a {@link android.content.BroadcastReceiver} |
28 | | - * will be created to receive the Intent corresponding to the given actions |
29 | | - * and it will call the annotated method. |
| 25 | + * This annotation is intended to be used on methods of an {@link EActivity}, |
| 26 | + * {@link EFragment} or {@link EService}. When this annotation is used, a |
| 27 | + * {@link android.content.BroadcastReceiver} will be created to receive the |
| 28 | + * Intent corresponding to the given actions and it will call the annotated |
| 29 | + * method. |
30 | 30 | * </p> |
31 | 31 | * <p> |
32 | 32 | * The annotated method MUST return void and MAY have one parameter: |
33 | 33 | * </p> |
34 | 34 | * <ul> |
35 | | - * <li>An {@link android.content.Intent}</li> |
| 35 | + * <li>An {@link android.content.Intent}</li> |
36 | 36 | * </ul> |
37 | 37 | * <p> |
38 | | - * The annotation has three parameters: |
| 38 | + * The annotation has four parameters: |
39 | 39 | * </p> |
40 | 40 | * <ul> |
41 | | - * <li> |
42 | | - * {@link #actions()}: One or several {@link java.lang.String} indicating the actions which will spark the method. |
43 | | - * This parameter is MANDATORY |
44 | | - * </li> |
45 | | - * <li> |
46 | | - * {@link #registerAt()}: The moment when the {@link android.content.BroadcastReceiver} |
47 | | - * will be registered and unregistered. By default : OnCreate/OnDestroy. |
48 | | - * The available values depend on the enclosing enhanced component. |
49 | | - * |
50 | | - * </li> |
51 | | - * <li> |
52 | | - * {@link #local()}: Specify whether android.support.v4.content.LocalBroadcastManager should be used. |
53 | | - * To use android.support.v4.content.LocalBroadcastManager, you MUST have android support-v4 in your classpath. |
54 | | - * Default value is false. |
55 | | - * </li> |
| 41 | + * <li> |
| 42 | + * {@link #actions()}: One or several {@link java.lang.String} indicating the |
| 43 | + * actions which will spark the method. This parameter is MANDATORY</li> |
| 44 | + * <li> |
| 45 | + * {@link #dataSchemes()}: One or several {@link java.lang.String} indicating |
| 46 | + * the data schemes which should be handled.</li> |
| 47 | + * <li> |
| 48 | + * {@link #registerAt()}: The moment when the |
| 49 | + * {@link android.content.BroadcastReceiver} will be registered and |
| 50 | + * unregistered. By default : OnCreate/OnDestroy. The available values depend on |
| 51 | + * the enclosing enhanced component.</li> |
| 52 | + * <li> |
| 53 | + * {@link #local()}: Specify whether |
| 54 | + * android.support.v4.content.LocalBroadcastManager should be used. To use |
| 55 | + * android.support.v4.content.LocalBroadcastManager, you MUST have android |
| 56 | + * support-v4 in your classpath. Default value is false.</li> |
56 | 57 | * </ul> |
57 | 58 | * |
58 | 59 | * <blockquote> |
|
62 | 63 | * <pre> |
63 | 64 | * @EActivity |
64 | 65 | * public class MyActivity { |
65 | | - * |
66 | | - * @Receiver(actions={{@link android.net.wifi.WifiManager#WIFI_STATE_CHANGED_ACTION}}) |
| 66 | + * |
| 67 | + * @Receiver(actions = {@link android.net.wifi.WifiManager#WIFI_STATE_CHANGED_ACTION}) |
67 | 68 | * public void onWifiStateChanged(Intent intent); |
68 | | - * |
69 | | - * @Receiver(actions={{@link android.net.wifi.WifiManager#WIFI_STATE_CHANGED_ACTION}}, registerAt=RegisterAt.OnResumeOnPause} |
| 69 | + * |
| 70 | + * @Receiver(actions = {@link android.net.wifi.WifiManager#WIFI_STATE_CHANGED_ACTION}, registerAt = RegisterAt.OnResumeOnPause) |
70 | 71 | * public void onWifiStateChangedWithoutIntent(); |
71 | | - * |
| 72 | + * |
| 73 | + * @Receiver(actions = {@link android.content.Intent#ACTION_VIEW}, dataSchemes = "http") |
| 74 | + * public void onHttpUrlOpened(Intent intent); |
| 75 | + * |
| 76 | + * @Receiver(actions = {@link android.content.Intent#ACTION_VIEW}, dataSchemes = {"http", "https"}) |
| 77 | + * public void onHttpOrHttpsUrlOpened(Intent intent); |
| 78 | + * |
72 | 79 | * } |
73 | 80 | * </pre> |
74 | 81 | * |
|
81 | 88 |
|
82 | 89 | String[] actions(); |
83 | 90 |
|
| 91 | + String[] dataSchemes() default {}; |
| 92 | + |
84 | 93 | RegisterAt registerAt() default RegisterAt.OnCreateOnDestroy; |
85 | 94 |
|
86 | 95 | boolean local() default false; |
87 | 96 |
|
88 | 97 | public enum RegisterAt { |
89 | | - OnCreateOnDestroy, |
90 | | - OnStartOnStop, |
91 | | - OnResumeOnPause, |
92 | | - OnAttachOnDetach |
| 98 | + OnCreateOnDestroy, OnStartOnStop, OnResumeOnPause, OnAttachOnDetach |
93 | 99 | } |
94 | 100 | } |
0 commit comments