openharmony 鸿蒙 capi-transient-task-api-h

2026-08-25 浏览 (1)

transient_task_api.h

Overview

The transient_task_api.h file declares the APIs for requesting, querying, and canceling transient tasks.

File to include: <transient_task/transient_task_api.h>

Library: libtransient_task.so

System capability: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask

Since: 13

Related module: TransientTask

Summary

Functions

NameDescription
int32_t OH_BackgroundTaskManager_RequestSuspendDelay(const char* reason, TransientTask_Callback callback, TransientTask_DelaySuspendInfo *info)Requests a transient task.
int32_t OH_BackgroundTaskManager_GetRemainingDelayTime(int32_t requestId, int32_t *delayTime)Obtains the remaining time of a transient task.
int32_t OH_BackgroundTaskManager_CancelSuspendDelay(int32_t requestId)Cancels a transient task.
int32_t OH_BackgroundTaskManager_GetTransientTaskInfo(TransientTask_TransientTaskInfo *transientTaskInfo)Obtains all information about a transient task, including the remaining quota of the current day.

Function Description

OH_BackgroundTaskManager_RequestSuspendDelay()

int32_t OH_BackgroundTaskManager_RequestSuspendDelay(const char* reason, TransientTask_Callback callback, TransientTask_DelaySuspendInfo *info)

Description

Requests a transient task.

System capability: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask

Since: 13

Parameters

NameDescription
const char* reasonReason for requesting the transient task.
TransientTask_Callback callbackCallback used to notify the application that the transient task is about to time out. Generally, the callback is invoked 6 seconds before the timeout.
TransientTask_DelaySuspendInfo *infoInformation about the transient task.

Return value

TypeDescription
int32_tReturns 0 if the operation is successful.
Returns 401 if the input parameter is incorrect.
Returns 9800002 if the Parcel read/write operation fails.
Returns 9800003 if the IPC fails.
Returns 9800004 if the system service fails.
Returns 9900001 if the client information of the transient task fails to be verified.
Returns 9900002 if the server information of the transient task fails to be verified.
For details about the error codes, see TransientTask_ErrorCode.

OH_BackgroundTaskManager_GetRemainingDelayTime()

int32_t OH_BackgroundTaskManager_GetRemainingDelayTime(int32_t requestId, int32_t *delayTime)

Description

Obtains the remaining time of a transient task.

System capability: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask

Since: 13

Parameters

NameDescription
int32_t requestIdRequest ID of the transient task.
int32_t *delayTimePointer to the remaining time of the transient task, in ms.

Return value

TypeDescription
int32_tReturns 0 if the operation is successful.
Returns 401 if the input parameter is incorrect.
Returns 9800002 if the Parcel read/write operation fails.
Returns 9800003 if the IPC fails.
Returns 9800004 if the system service fails.
Returns 9900001 if the client information of the transient task fails to be verified.
Returns 9900002 if the server information of the transient task fails to be verified.
For details about the error codes, see TransientTask_ErrorCode.

OH_BackgroundTaskManager_CancelSuspendDelay()

int32_t OH_BackgroundTaskManager_CancelSuspendDelay(int32_t requestId)

Description

Cancels a transient task.

System capability: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask

Since: 13

Parameters

NameDescription
int32_t requestIdRequest ID of the transient task.

Return value

TypeDescription
int32_tReturns 0 if the operation is successful.
Returns 401 if the input parameter is incorrect.
Returns 9800002 if the Parcel read/write operation fails.
Returns 9800003 if the IPC fails.
Returns 9800004 if the system service fails.
Returns 9900001 if the client information of the transient task fails to be verified.
Returns 9900002 if the server information of the transient task fails to be verified.
For details about the error codes, see TransientTask_ErrorCode.

OH_BackgroundTaskManager_GetTransientTaskInfo()

int32_t OH_BackgroundTaskManager_GetTransientTaskInfo(TransientTask_TransientTaskInfo *transientTaskInfo)

Description

Obtains all information about a transient task, including the remaining quota of the current day.

Since: 20

Parameters

NameDescription
TransientTask_TransientTaskInfo *transientTaskInfoAll information about a transient task. For details, see TransientTask_TransientTaskInfo.

Return value

TypeDescription
int32_tReturns 0 if the operation is successful.
Returns 9900001 if the client information of the transient task fails to be verified.
Returns 9900003 if the Parcel read/write operation fails.
Returns 9900004 if the system service fails.
For details about the error codes, see TransientTask_ErrorCode.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 js-apis-backgroundTaskManager

openharmony 鸿蒙 errorcode-DeviceUsageStatistics

openharmony 鸿蒙 capi-transient-task-type-h

openharmony 鸿蒙 errorcode-backgroundTaskMgr

openharmony 鸿蒙 js-apis-WorkSchedulerExtensionContext

openharmony 鸿蒙 js-apis-reminderAgent

openharmony 鸿蒙 errorcode-backgroundProcessManager

openharmony 鸿蒙 js-apis-WorkSchedulerExtensionAbility

openharmony 鸿蒙 errorcode-reminderAgentManager

openharmony 鸿蒙 capi-transienttask-transienttask-transienttaskinfo

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/OMm4tXsc