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' 19 20const TAG = 'MainAbility' 21 22export default class MainAbility extends UIAbility { 23 onCreate(want, launchParam) { 24 Log.log(TAG, "MainAbility onCreate"); 25 globalThis.abilityWant = want; 26 globalThis.context = this.context; 27 } 28 29 onDestroy() { 30 Log.log(TAG, "MainAbility onDestroy"); 31 } 32 33 onWindowStageCreate(windowStage) { 34 // Main window is created, set main page for this ability 35 Log.log(TAG, "MainAbility onWindowStageCreate"); 36 37 windowStage.setUIContent(this.context, "pages/index", null); 38 } 39 40 onWindowStageDestroy() { 41 // Main window is destroyed, release UI related resources 42 Log.log(TAG, "MainAbility onWindowStageDestroy"); 43 } 44 45 onForeground() { 46 // Ability has brought to foreground 47 Log.log(TAG, "MainAbility onForeground"); 48 } 49 50 onBackground() { 51 // Ability has back to background 52 Log.log(TAG, "MainAbility onBackground"); 53 } 54}; 55