10fbfc30aSopenharmony_ci/** 20fbfc30aSopenharmony_ci * @file Describe the file 30fbfc30aSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 40fbfc30aSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 50fbfc30aSopenharmony_ci * you may not use this file except in compliance with the License. 60fbfc30aSopenharmony_ci * You may obtain a copy of the License at 70fbfc30aSopenharmony_ci * 80fbfc30aSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 90fbfc30aSopenharmony_ci * 100fbfc30aSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 110fbfc30aSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 120fbfc30aSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130fbfc30aSopenharmony_ci * See the License for the specific language governing permissions and 140fbfc30aSopenharmony_ci * limitations under the License. 150fbfc30aSopenharmony_ci */ 160fbfc30aSopenharmony_ci 170fbfc30aSopenharmony_ciimport UIAbility from '@ohos.app.ability.UIAbility'; 180fbfc30aSopenharmony_ciimport { Log } from '@ohos/common/src/main/ets/utils/Log' 190fbfc30aSopenharmony_ciimport Want from '@ohos.app.ability.Want'; 200fbfc30aSopenharmony_ciimport window from '@ohos.window'; 210fbfc30aSopenharmony_ci 220fbfc30aSopenharmony_ciconst TAG = 'Application'; 230fbfc30aSopenharmony_ci 240fbfc30aSopenharmony_ciexport default class Application extends UIAbility { 250fbfc30aSopenharmony_ci onCreate(want: Want) { 260fbfc30aSopenharmony_ci Log.log(TAG, "MainAbility onCreate"); 270fbfc30aSopenharmony_ci } 280fbfc30aSopenharmony_ci 290fbfc30aSopenharmony_ci onDestroy() { 300fbfc30aSopenharmony_ci Log.log(TAG, "MainAbility onDestroy"); 310fbfc30aSopenharmony_ci } 320fbfc30aSopenharmony_ci 330fbfc30aSopenharmony_ci onWindowStageCreate(windowStage: window.WindowStage) { 340fbfc30aSopenharmony_ci // Main window is created, set main page for this ability 350fbfc30aSopenharmony_ci Log.log(TAG, "MainAbility onWindowStageCreate"); 360fbfc30aSopenharmony_ci 370fbfc30aSopenharmony_ci windowStage.loadContent("pages/index", (err, data) => { 380fbfc30aSopenharmony_ci if (err?.code) { 390fbfc30aSopenharmony_ci console.error('Failed to load the content. Cause:' + JSON.stringify(err)); 400fbfc30aSopenharmony_ci return; 410fbfc30aSopenharmony_ci } 420fbfc30aSopenharmony_ci console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); 430fbfc30aSopenharmony_ci }); 440fbfc30aSopenharmony_ci } 450fbfc30aSopenharmony_ci 460fbfc30aSopenharmony_ci onWindowStageDestroy() { 470fbfc30aSopenharmony_ci // Main window is destroyed, release UI related resources 480fbfc30aSopenharmony_ci Log.log(TAG, "MainAbility onWindowStageDestroy"); 490fbfc30aSopenharmony_ci } 500fbfc30aSopenharmony_ci 510fbfc30aSopenharmony_ci onForeground() { 520fbfc30aSopenharmony_ci // Ability has brought to foreground 530fbfc30aSopenharmony_ci Log.log(TAG, "MainAbility onForeground"); 540fbfc30aSopenharmony_ci } 550fbfc30aSopenharmony_ci 560fbfc30aSopenharmony_ci onBackground() { 570fbfc30aSopenharmony_ci // Ability has back to background 580fbfc30aSopenharmony_ci Log.log(TAG, "MainAbility onBackground"); 590fbfc30aSopenharmony_ci } 600fbfc30aSopenharmony_ci}; 61