1import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
2import { hilog } from '@kit.PerformanceAnalysisKit';
3import { window } from '@kit.ArkUI';
4
5export default class EntryAbility extends UIAbility {
6  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
7    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
8  }
9
10  onDestroy(): void {
11    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
12  }
13
14  onWindowStageCreate(windowStage: window.WindowStage): void {
15    // Main window is created, set main page for this ability
16    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
17
18    windowStage.loadContent('pages/Index', (err) => {
19      if (err.code) {
20        hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
21        return;
22      }
23      hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
24    });
25  }
26
27  onWindowStageDestroy(): void {
28    // Main window is destroyed, release UI related resources
29    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
30  }
31
32  onForeground(): void {
33    // Ability has brought to foreground
34    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
35  }
36
37  onBackground(): void {
38    // Ability has back to background
39    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
40  }
41};
42