code: public synchronized void sendQueuedEvents(KeenProject project, KeenCallback callback) {
  
          if (!isActive) {
              handleLibraryInactive(callback);
              return;
          }
  
          if (project == null && defaultProject == null) {
              handleFailure(null, new IllegalStateException("No project specified, but no default project found"));
              return;
          }
  
          if (!isNetworkConnected()) {
              KeenLogging.log("Not sending events because there is no network connection. " +
                              "Events will be retried next time `sendQueuedEvents` is called.");
              handleFailure(callback, new Exception("Network not connected."));
              return;
          }
  
          KeenProject useProject = (project == null ? defaultProject : project);
  
          try {
              String projectId = useProject.getProjectId();
              Map<String, List<Object>> eventHandles = eventStore.getHandles(projectId);
              Map<String, List<Map<String, Object>>> events = buildEventMap(projectId, eventHandles);
              String response = publishAll(useProject, events);
              if (response != null) {
                  try {
                      handleAddEventsResponse(eventHandles, response);
                  } catch (Exception e) {
                      // Errors handling the response are non-fatal; just log them.
                      KeenLogging.log("Error handling response to batch publish: " + e.getMessage());
                  }
              }
              handleSuccess(callback);
          } catch (Exception e) {
              handleFailure(callback, e);
          }
      }
docs: Synchronously sends all queued events for the given project. This method will immediately
  publish the events to the Keen server in the current thread.
  
  @param project  The project for which to send queued events. If a default project has been set
  on the client this parameter may be null, in which case the default project
  will be used.
  @param callback An optional callback to receive notification of success or failure.