@ohos.backgroundTaskManager (Background Task Management) (System API)

The BackgroundTaskManager module provides APIs to manage background tasks.

If a service needs to be continued when the application or service module is running in the background (not visible to users), the application or service module can request a transient task to delay the suspension or a continuous task to prevent the suspension.

If an application has a task that needs to be continued when the application is switched to the background and can be completed within a short period of time, the application can request a transient task. For example, if a user chooses to clear junk files in the Files application and exits the application, the application can request a transient task to complete the cleanup.

If an application has a service that can be intuitively perceived by users and needs to run in the background for a long period of time (for example, music playback in the background), the application can request a continuous task.

If a privileged system application needs to use certain system resources (for example, it wants to receive common events when suspended), it can request efficiency resources.

NOTE

Modules to Import

import backgroundTaskManager from '@ohos.backgroundTaskManager';  

BackgroundMode8+

System capability: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask

Name Value Description
WIFI_INTERACTION 7 WLAN-related.
This is a system API.
VOIP 8 Audio and video calls.
This is a system API.