Tag: 接收器

如何访问在BroadcastReceivers中的MainActivity(布局)中声明的Switch按钮

我有一项任务,当飞机模式为ON / OFF时,我必须改变开关按钮的状态。 我有一个主要活动,我宣布Switch Button,我想从BroadcastReceiver Class更改Switch的状态开/关 接收器 public class MyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { boolean isAirplaneModeOn = intent.getBooleanExtra(“state”, false); if(isAirplaneModeOn){ What Should i do ? } } } layout_main_activity