• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * @file Describe the file
3 * Copyright (c) 2023 Huawei Device Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17import UIAbility from '@ohos.app.ability.UIAbility';
18import { Log } from '@ohos/common/src/main/ets/utils/Log'
19import Want from '@ohos.app.ability.Want';
20import window from '@ohos.window';
21
22const TAG = 'Application';
23
24export default class Application extends UIAbility {
25  onCreate(want: Want) {
26    Log.log(TAG, "MainAbility onCreate");
27  }
28
29  onDestroy() {
30    Log.log(TAG, "MainAbility onDestroy");
31  }
32
33  onWindowStageCreate(windowStage: window.WindowStage) {
34    // Main window is created, set main page for this ability
35    Log.log(TAG, "MainAbility onWindowStageCreate");
36
37    windowStage.loadContent("pages/index", (err, data) => {
38      if (err?.code) {
39        console.error('Failed to load the content. Cause:' + JSON.stringify(err));
40        return;
41      }
42      console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
43    });
44  }
45
46  onWindowStageDestroy() {
47    // Main window is destroyed, release UI related resources
48    Log.log(TAG, "MainAbility onWindowStageDestroy");
49  }
50
51  onForeground() {
52    // Ability has brought to foreground
53    Log.log(TAG, "MainAbility onForeground");
54  }
55
56  onBackground() {
57    // Ability has back to background
58    Log.log(TAG, "MainAbility onBackground");
59  }
60};
61