Code example for Intent

Methods: getActiongetIntExtra

0
  } 
 
  private final class PowerStatusReceiver extends BroadcastReceiver {
    @Override 
    public void onReceive(Context context, Intent intent){
      if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
        // 0 indicates that we're on battery 
        boolean onBatteryNow = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) <= 0;
        if (onBatteryNow) {
          InactivityTimer.this.onActivity();
        } else { 
          InactivityTimer.this.cancel();
        } 
      } 
    } 
  } 
 
  private final class InactivityAsyncTask extends AsyncTask<Object,Object,Object> {
    @Override 
    protected Object doInBackground(Object... objects) {
      try {