private Context mcuContext = null;
private Intent intent = new Intent("UpdateMCU");
public UpdateMCU(Context context) {
super(true);
this.mcuContext = context;
IntentFilter filter = new IntentFilter();
filter.addAction("UpdateMCU");
mcuContext.registerReceiver(receiverTime, filter);//注册广播
}
private final BroadcastReceiver receiverTime = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals("UpdateMCU")) {
int index = intent.getIntExtra("ID", 0);
delData(index);//
}
}
};
mcuContext.unregisterReceiver(receiverTime);//取消广播
android之广播Broadcast使用
最新推荐文章于 2024-08-17 00:03:17 发布