title: How to get switch value in Android?
body: <p>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.</p>
  
  <p>If I type</p>
  
  <pre><code>Switch s = (Switch) findViewById(R.id.switch1);
  </code></pre>
  
  <p>it says findViewById is undefined for the type SecondActivity. The problem is Android doesn't allow me to get the value of switch in a class that extends Broadcast Receiver.</p>
  
  <p>I want to know the state of switch, i.e, whether switch is on or off, but in second activity. How can I achieve it?</p>