I have placed a switch widget in Main Activity, I also have a second activity that extends BroadcastReceiver. I want to get the boolean state of switch widget in second activity
To access the value of the switch, you need to do the following:
((Switch) findViewById(R.id.switch_id)).isChecked();
BUT in a context of a BroadcastReceiver, you don't have really access to a layout, therefore you can't access the switch. You have to perform this ONLY within the Activity that inflates the layout that has the Switch.
You may have a BroadcastReceiver registered programmatically within an Activity, this is the only way I see this mixture of concepts working.