@Override
  public void onScreenOff() {
    Logger.d(TAG, "Screen Off");

    isScreenVisible = false;
    onAppProbablyClosed();
  }
 @Override
 public void onActivityOpen() {
   Logger.d(TAG, "Activity open");
   activityCount++;
   if (isScreenVisible) {
     onAppProbablyOpened();
   }
 }
  @Override
  public void onScreenOn() {
    Logger.d(TAG, "Screen On");

    isScreenVisible = true;
    if (activityCount > 0) {
      onAppProbablyOpened();
    }
  }
  @Override
  public void onActivityClose() {
    Logger.d(TAG, "Activity close");
    activityCount--;

    if (activityCount == 0) {
      onAppProbablyClosed();
    }
  }
 private void onAppClosed() {
   Logger.d(TAG, "App closed");
   Core.messenger().onAppHidden();
 }
 private void onAppOpened() {
   Logger.d(TAG, "App open");
   Core.messenger().onAppVisible();
 }