AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones específicas para móviles / Funciones de tareas en segundo plano
  • Presentación
  • Implementación
  • En el editor
  • Mediante programación
  • Modo de funcionamiento
  • Características específicas
  • Android specific features
  • Specific features for iOS
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Otros
Procedimientos almacenados
Presentación
Seguir ejecutando un Process cuando la aplicación está en segundo plano es muy useful en el móvil:
  • recordatorio de cita (mostrar un Notification),
  • cálculo del volumen de negocios en tiempo real,
  • recuperación de datos, ....
El proceso debe simplemente estar presente en un procedimiento. Todo lo que tiene que hacer es especificar la frecuencia con la que se ejecutará este procedimiento.
Entre las llamadas, el procedimiento no consume ni batería ni CPU.
Implementación

En el editor

Para automatizar a Procedure:
  1. Mostrar el código de la Procedure.
  2. Abre la ventana de la description de las automatizaciones de la Procedure:
    • Haga clic en Icon en la barra de Procedure.
    • Seleccione la opción "Configurar procesos automatizados del procedimiento" en el menú contextual del procedimiento (en el panel "Explorador de proyectos").
    • Seleccione "Propiedades" en el menú contextual de la Procedure en el panel "Código".
  3. En la ventana que aparece, seleccione el tipo de automatización: "Ejecutar periódicamente cuando la aplicación está en segundo plano".
  4. Especifique el tiempo interval (en minutos). Este interval es el tiempo mínimo interval entre dos ejecuciones de tareas. Se utiliza para garantizar que la tarea no se ejecutará durante este tiempo interval. Sin embargo, el sistema puede aumentar el tiempo de interval de acuerdo con varios factores (carga de trabajo importante, batería baja, etc.). Por lo tanto, el tiempo real interval puede cambiar y puede ser bastante largo (varias horas).
  5. Validar.

Mediante programación

Para añadir una tarea Background, utilice BackgroundTaskAdd.
Observación: También puede manipular Background tareas utilizando las siguientes funciones:
BackgroundTaskDeleteBorra una tarea de Background (que fue añadida por Background TaskAdd).
BackgroundTaskListDevuelve la lista de tareas de Background para la aplicación.

Modo de funcionamiento

Once added, the background task is automatically run by the system at regular time interval.
The task is persistent, it will continue to be run periodically when the application is stopped, even when the device is restarted.
If the task is triggered while the application is not started, the application will be run in background (without opening the first project window), the initialization process of project and the declaration process of classes and sets of procedures will be run before calling the procedure associated with the task.
The task will be run when the application is not started or when the application is in background. If the application is displayed in the foreground, its execution will be postponed.
As the task can be run in a secondary thread of the application, the code of the WLanguage procedure must not contain an access to the application's UI or open dialog boxes (via Info, Error, etc.). If the task must interact with the users, you can use notifications (Notifxxx functions).
Características específicas
Android

Android specific features

  • If the task is to run while the device is in standby mode, it is recommended to ask the user to disable battery optimization for this application with SysBatteryOptimBackground.
  • Debugging:
    For debugging purposes, you can force the execution of a background task via ADB by using the following command line:
    adb shell cmd jobscheduler run -f <application> <id>

    where:
    • <application> corresponds to the package name of application as defined in the generation wizard (ex: com.mycompany.myapplication).
    • <id> is the identifier of task to run (returned by BackgroundTaskAdd).
  • Required version:
    Background tasks can only be added on devices running Android 5.0 or later (API level 21).
    A fatal error occurs if the function is used with an earlier system version.
    To determine the version of Android the application is running on, use SysAndroidVersion.
  • Required permissions:
    Using this function modifies the permissions required by the application.
    Required permissions:
    RECEIVE_BOOT_COMPLETED: allows an application to receive the ACTION_BOOT_COMPLETED that is diffused after the system finishes booting.
  • Once run, the task in background continues to operate as long as the application is installed.
  • The tasks in background are not called in the simulator.
iPhone/iPad

Specific features for iOS

  • Runtime duration:
    The background tasks have a total of 30 seconds to be run. If this timeout is exceeded, the application is directly stopped (this timeout can be reduced according to the system availability). Therefore, the task execution must be as fast as possible.
    Practically, the system uses the execution time of task to define the real frequency at which it must be called.
  • Debugging:
    You have the ability to debug the background tasks via Xcode, by triggering them manually via "Debug .. Simulate Background Fetch".
  • In order for the system to consider that the application can run background tasks, the application must perform network requests (calls to web services, HTTP requests, access to an HFSQL database, GPS, Email, ...). Indeed, iOS checks whether the application exploits data coming from the network.
  • The application must be able to run background tasks. On the device, in the "Device parameters .. Application name", the option "Refresh in background" must be checked.
  • When the application is specifically closed by a double press on the Home button and a swipe, the background procedure has less chances to be run.
  • The procedure will not be called anymore if the devices switches to "energy saving" mode.
  • The timeout between two procedure executions will be reduced if the device is plugged and connected to a WiFi network.
  • The frequency at which the application is enabled by the user will impact the call frequency of procedure.
  • The faster the request execution is, the shorter the time between two executions. In most cases, a long execution time of procedure means that the calls will be spaced out in time. The system gives priority to the procedures that consume less CPU.
Versión mínima requerida
  • Versión 23
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/01/2023

Señalar un error o enviar una sugerencia | Ayuda local