• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import Ability from '@ohos.app.ability.UIAbility'
2import Window from '@ohos.window'
3import LogUtils from '../common/utils/LogUtils'
4
5const TAG = "MainAbility";
6
7export default class MainAbility extends Ability {
8  onCreate(want, launchParam) {
9    LogUtils.i(TAG, "onCreate")
10    globalThis.settingsAbilityContext = this.context;
11  }
12
13  onDestroy() {
14    LogUtils.i(TAG, "onDestroy")
15  }
16
17  onWindowStageCreate(windowStage: Window.WindowStage) {
18    // Main window is created, set main page for this ability
19    LogUtils.i(TAG, "onWindowStageCreate")
20
21    windowStage.loadContent('pages/index', (err, data) => {
22      if (err.code) {
23        LogUtils.e(TAG, 'Failed to load the content. Cause:' + JSON.stringify(err));
24        return;
25      }
26      LogUtils.e(TAG, 'Succeeded in loading the content. Data: ' + JSON.stringify(data))
27    });
28  }
29
30  onWindowStageDestroy() {
31    // Main window is destroyed, release UI related resources
32    LogUtils.i(TAG, "onWindowStageDestroy")
33  }
34
35  onForeground() {
36    // Ability has brought to foreground
37    LogUtils.i(TAG, "onForeground")
38  }
39
40  onBackground() {
41    // Ability has back to background
42    LogUtils.i(TAG, "onBackground")
43  }
44}
45