1# @ohos.app.appstartup.StartupListener (Startup Task Listener) 2<!--Kit: Ability Kit--> 3<!--Subsystem: Ability--> 4<!--Owner: @yzkp--> 5<!--Designer: @yzkp--> 6<!--Tester: @lixueqing513--> 7<!--Adviser: @huipeizi--> 8 9 10The module provides APIs to listen for startup tasks. 11 12> **NOTE** 13> 14> 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. 15> 16> The APIs of this module can be used only in the stage model. 17 18## Modules to Import 19 20```ts 21import { StartupListener } from '@kit.AbilityKit'; 22``` 23 24## StartupListener.onCompleted 25 26onCompleted?(error: BusinessError\<void\>): void 27 28Called when all startup tasks are complete. 29 30**System capability**: SystemCapability.Ability.AppStartup 31 32**Parameters** 33 34| Name| Type| Mandatory| Description| 35| -------- | -------- | -------- | -------- | 36| error | [BusinessError\<void>](../apis-basic-services-kit/js-apis-base.md#businesserror) | Yes| Error message.| 37 38**Example** 39 40```ts 41import { StartupConfig, StartupConfigEntry, StartupListener } from '@kit.AbilityKit'; 42import { BusinessError } from '@kit.BasicServicesKit'; 43import { hilog } from '@kit.PerformanceAnalysisKit'; 44 45export default class MyStartupConfigEntry extends StartupConfigEntry { 46 onConfig() { 47 hilog.info(0x0000, 'testTag', `onConfig`); 48 let onCompletedCallback = (error: BusinessError<void>) => { 49 hilog.info(0x0000, 'testTag', `onCompletedCallback`); 50 if (error) { 51 hilog.error(0x0000, 'testTag', 'onCompletedCallback: %{public}d, message: %{public}s', error.code, 52 error.message); 53 } else { 54 hilog.info(0x0000, 'testTag', `onCompletedCallback: success.`); 55 } 56 }; 57 let startupListener: StartupListener = { 58 'onCompleted': onCompletedCallback 59 }; 60 let config: StartupConfig = { 61 'timeoutMs': 10000, 62 'startupListener': startupListener 63 }; 64 return config; 65 } 66} 67``` 68