@Override
  public void onAttachedToWindow() {
    super.onAttachedToWindow();

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_BATTERY_CHANGED);
    filter.addAction(ACTION_LEVEL_TEST);
    final Intent sticky = getContext().registerReceiver(mTracker, filter);
    if (sticky != null) {
      // preload the battery level
      mTracker.onReceive(getContext(), sticky);
    }

    mAttached = true;
  }