code: public AppEventsLogger getAppEventsLogger() {
          Session session = Session.getActiveSession();
          if (session == null) {
              return null;
          }
  
          if (appEventsLogger == null || !appEventsLogger.isValidForSession(session)) {
              if (appEventsLogger != null) {
                  // Pretend we got stopped so the old logger will persist its results now, in case we get stopped
                  // before events get flushed.
                  AppEventsLogger.onContextStop();
              }
              appEventsLogger = AppEventsLogger.newLogger(activity, session);
          }
  
          return appEventsLogger;
      }
docs: Retrieves an instance of AppEventsLogger that can be used for the current Session, if any. Different
  instances may be returned if the current Session changes, so this value should not be cached for long
  periods of time -- always call getAppEventsLogger to get the right logger for the current Session. If
  no Session is currently available, this method will return null.
  
  To ensure delivery of app events across Activity lifecycle events, calling Activities should be sure to
  call the onStop method.
  
  @return an AppEventsLogger to use for logging app events