Code example for Activity

Methods: registerReceiver

0
    cancel(); 
    activity.unregisterReceiver(powerStatusReceiver);
  } 
 
  public void onResume(){ 
    activity.registerReceiver(powerStatusReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    onActivity(); 
  } 
 
  private synchronized  void cancel() { 
    AsyncTask<?,?,?> task = inactivityTask;
    if (task != null) {
      task.cancel(true);
      inactivityTask = null;
    } 
  } 
 
  void shutdown() { 
    cancel(); 
  }