目录

About This Kit

Introduction

Operations such as returning to the home screen, locking the screen, and switching applications cause an application to move to the background. After an application moves to the background, if it continues running in the background, it may cause the device to consume power quickly and the UI to become sluggish. To reduce power consumption and ensure a smooth user experience, the system manages applications that have moved to the background, including process suspension and process termination. Typical scenarios include: after an application moves to the background for a period of time, its application process is suspended; when resources are insufficient, the system terminates some application processes (that is, reclaims all resources of those processes). After an application process is suspended, it cannot use software resources (such as common events and timers) or hardware resources (such as the CPU, network, GPS, and Bluetooth).For details about how to properly use resources, see Proper Use of Background Hardware Resources.

To ensure that background functionalities such as music playback and calendar reminders can be used properly, Background Tasks Kit provides some background tasks within the specifications, extending the running time of applications in the background.

Constraints

Resource usage: The system provides resource quotas for running processes, including the memory usage and CPU Usage in a continuous period of time, and disk write I/O volume in 24 hours. When the quota is reached, the system generates a warning-level log if the process is running in the foreground, and terminates the process if it is running in the background.

Background Task Types

Background Tasks Kit provides the following types of constrained background tasks: transient tasks, continuous tasks, deferred tasks, agent-powered reminders.

You can select a proper background task type to ensure that your application can continue running after switching to the background.

  1. The system supports only constrained background tasks. If an application does not use a constrained background task or selects an inappropriate type of background task after switching to the background, its process will be suspended or terminated.

  2. For an application that requests a constrained background task, only the priority of reclaiming the application process is increased. If system resources are severely insufficient, the application process may still be terminated.

Emulator Support

This kit supports the Emulator, but there are some differences in feature support between real devices and the Emulator:

Integration Standards and Penalties for Non-compliance

When using continuous tasks, your application must comply with the integration requirements and restrictions. Any behavior that violates the requirements and affects user experience will be considered a violation. For details about violations and corresponding penalties, see Violation and Penalty Policy.