title: Android : How to use registerReceiver in BroadcastReceiver
body: <p>I want to perform some task when I get <code>ACTION_BOOT_COMPLETED</code> intent, i'm using following code to check if device is plugged in but I get <em>method is undefined for the type BootReceiver</em> at <code>registerReceiver</code>. Can anyone find the solution? here is what i'm doing.</p>
  
  <pre><code>public class BootReceiver extends BroadcastReceiver {
  
  @Override
  public void onReceive(final Context context, Intent intent) {
  
      if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) {
  
      if(isCharging())
      doSomething();  //something to perform after boot if plugged in
  
          }
  
  
  
          public boolean isCharging() {
      IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
      Intent batteryStatus = registerReceiver(null, filter); //getting error here
  
      boolean strState;
  
      int chargeState = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
  
      switch (chargeState) {
          case BatteryManager.BATTERY_STATUS_CHARGING:
          case BatteryManager.BATTERY_STATUS_FULL:
              strState = true;
              break;
          default:
              strState = false;
      }
      return strState;
  
      }
  
  }
  </code></pre>