harmony 鸿蒙@ohos.app.appstartup.StartupTask
@ohos.app.appstartup.StartupTask
The StartupTask module provides APIs related to startup tasks.
NOTE
The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The APIs of this module can be used only in the stage model.
Modules to Import
import { StartupTask } from '@kit.AbilityKit';
StartupTask.onDependencyCompleted
onDependencyCompleted?(dependency: string, result: ESObject): void
Called when the dependent startup task is complete.
System capability: SystemCapability.Ability.AppStartup
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
dependency | string | Yes | Name of the dependent startup task. |
result | Object | Yes | Execution result of the dependent startup task. |
Example
import StartupTask from '@ohos.app.appstartup.StartupTask';
import common from '@ohos.app.ability.common';
import hilog from '@ohos.hilog';
@Sendable
export default class StartupTask_001 extends StartupTask {
constructor() {
super();
}
async init(context: common.AbilityStageContext) {
// ...
}
onDependencyCompleted(dependence: string, result: Object): void {
hilog.info(0x0000, 'testTag', 'StartupTask_001 onDependencyCompleted, dependence: %{public}s, result: %{public}s',
dependence, JSON.stringify(result));
// ...
}
}
StartupTask.init
init(context: AbilityStageContext): Promise<ESObject>
Initializes this startup task.
System capability: SystemCapability.Ability.AppStartup
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
context | AbilityStageContext | Yes | Context of the ability stage. |
Return value
Type | Description |
---|---|
Promise<Object |void> | Promise used to return the execution result. |
Example
import { StartupTask, common } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
@Sendable
export default class StartupTask_001 extends StartupTask {
constructor() {
super();
}
async init(context: common.AbilityStageContext) {
hilog.info(0x0000, 'testTag', 'StartupTask_001 init.');
// ...
return "StartupTask_001";
}
onDependencyCompleted(dependence: string, result: Object): void {
// ...
}
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙AbilityAccessControl
harmony 鸿蒙OH_NativeBundle_ApplicationInfo
harmony 鸿蒙OH_NativeBundle_ElementName
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦