class ForegroundNotifier implements Application.ActivityLifecycleCallbacks {

  @Override
  public void onActivityResumed(Activity activity) {
    paused = false;
    boolean wasBackground = !foreground;
    foreground = true;

    if (check != null) {
      handler.removeCallbacks(check);
    }

    if (wasBackground) {
      Logging.logi("went foreground");
      foregroundSubject.onNext(ON_FOREGROUND);
    }
  }

}