Saltar al contenido

Cargar registro usando valores del flujo

Pon el uploadLog método debajo de la parte inferior de la MainActivity sonó.

public void uploadLog() {
    LOGGER.debug("In uploadLog");
    myLogUploadListener = new Logging.UploadListener() {
        @Override
        public void onSuccess() {
            LOGGER.debug("Log upload completed");
            Toast.makeText(getApplicationContext(), "Log upload completed and was successful!",
                    Toast.LENGTH_LONG).show();
            Logging.removeLogUploadListener(myLogUploadListener);
        }

        @Override
        public void onError(@NonNull Throwable throwable) {
            LOGGER.debug("Log upload encountered an error with message: " + throwable.getMessage());
            Toast.makeText(getApplicationContext(), "Log upload failed with error message: " + throwable.getMessage(),
                    Toast.LENGTH_LONG).show();
            Logging.removeLogUploadListener(myLogUploadListener);
        }

        @Override
        public void onProgress(int percentUploaded) {
            LOGGER.debug("Log upload progress: " + percentUploaded);
        }
    };

    Logging.addLogUploadListener(myLogUploadListener);

      // String serviceURL = flowContext.getOnboardingParameters().getSettingsParameters().getBackendUrl();
      // String deviceID = flowContext.getOnboardingParameters().getSettingsParameters().getDeviceId();
      OkHttpClient okHttpClient = flowContext.getOkHttpClient();
      SettingsParameters sp = flowContext.getOnboardingParameters().getSettingsParameters();
      Logging.uploadLog(okHttpClient, sp, Logging.UploadType.MERGE);
}

El método anterior carga el registro existente en Servicios móviles y muestra el resultado de la acción. Note que el Logging.uploadLog requiere método OkHttpClient y SettingsParameters variables obtenidas de la flowContext.

Agregue la siguiente línea al onUploadLog método.

uploadLog();