title: Toggle state from broadcast recive android
body: <p>I have a toggle that when BATTERY_LOW is true turns off the wifi:</p>
  
  <pre><code>public void getToggle(View view) { 
      // Is the toggle on?
     boolean on = ((ToggleButton) view).isChecked(); 
      if (on) {
              PackageManager pm = getPackageManager();
      ComponentName compName = 
      new ComponentName(getApplicationContext(), 
          LowBatteryReceiver.class);
          pm.setComponentEnabledSetting(
          compName,
          PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 
          PackageManager.DONT_KILL_APP);
      } else {                
             PackageManager pm = getPackageManager();
             ComponentName compName = 
             new ComponentName(getApplicationContext(), 
             LowBatteryReceiver.class);
             pm.setComponentEnabledSetting(
             compName,
             PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 
             PackageManager.DONT_KILL_APP);           
        }
      }
  </code></pre>
  
  <p>here the wifi code:</p>
  
  <pre><code>public class LowBatteryReceiver extends BroadcastReceiver {
  
      public void onReceive(Context context, Intent intent) {
          wifiManager = (WifiManager) MainActivity.this.getSystemService(Context.WIFI_SERVICE); 
                          wifiManager.setWifiEnabled(false);
      }
  }
  
  
  public class OkBatteryReceiver extends BroadcastReceiver {
  
      public void onReceive(Context context, Intent intent) {
          wifiManager = (WifiManager) MainActivity.this.getSystemService(Context.WIFI_SERVICE); 
                          wifiManager.setWifiEnabled(true);
      }
  }
  </code></pre>
  
  <p>How can i "remember" the choice of the toggle when i go out from my application and open it again? I know that i have to write something at <code>onResume</code> and in the <code>onCreate</code> but i don't know what when i use the BroadcastReceiver.I think i have to check if the <code>COMPONENT_ENABLED_STATE_DISABLED</code> or <code>COMPONENT_ENABLED_STATE_ENABLED</code> right?.Someone can help me? Thanks</p>