|
@@ -0,0 +1,33 @@
|
|
|
+# AAPS & 翰思维尔 接收广播
|
|
|
+
|
|
|
+## 示例:
|
|
|
+
|
|
|
+```java
|
|
|
+//创建广播接收
|
|
|
+BroadcastReceiver receiver=new BroadcastReceiver(){
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onReceive(Context context,Intent data){
|
|
|
+ @NotNull String json=data.getString("data")
|
|
|
+ // foo
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 订阅广播
|
|
|
+IntentFilter intentFilter=IntentFilter();
|
|
|
+intentFilter.addAction(action)
|
|
|
+context.registerReceiver(receiver, intentFilter)
|
|
|
+
|
|
|
+// 注销订阅
|
|
|
+context.unregisterReceiver(receiver)
|
|
|
+```
|
|
|
+
|
|
|
+## 参数
|
|
|
+
|
|
|
+* action
|
|
|
+ * 类型:String,常量。
|
|
|
+ * 值:aaps.diy.actions.Info
|
|
|
+
|
|
|
+* data
|
|
|
+ * 类型:String,json字符串。
|
|
|
+ * 值:[点击查看具体](./data.md)
|