1/* 2 * Copyright (C) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import UIAbility from '@ohos.app.ability.UIAbility'; 17import AbilityConstant from '@ohos.app.ability.AbilityConstant'; 18import Want from '@ohos.app.ability.Want'; 19import window from '@ohos.window'; 20import { BusinessError } from '@ohos.base'; 21import hilog from '@ohos.hilog'; 22import { MyCallback } from '../models/MyCallback'; 23 24 25class EntryAbility extends UIAbility { 26 onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { 27 hilog.info(0x0000, 'testTag EntryAbility', 'EntryAbility onCreate'); 28 } 29 30 onWindowStageCreate(windowStage: window.WindowStage): void { 31 hilog.info(0x0000, 'testTag EntryAbility', 'EntryAbility onWindowStageCreate'); 32 try { 33 windowStage.loadContent('pages/Index', (err: BusinessError<void> | null): void => { 34 hilog.info(0x0000, 'testTag EntryAbility', 'loadContent entering'); 35 MyCallback.runCasesOfCallback(); 36 if (err?.code) { 37 hilog.info(0x0000, 'testTag EntryAbility', 'loadContent error'); 38 return; 39 } 40 hilog.info(0x0000, 'testTag EntryAbility', 'loadContent ok'); 41 }); 42 } catch (e: Error) { 43 hilog.info(0x0000, 'testTag EntryAbility', 'loadContent catch error:-----------' + e.message); 44 } 45 } 46 47 onDestroy() { 48 hilog.info(0x0000, 'testTag EntryAbility', '%{public}s', 'TestAbility onDestroy'); 49 } 50 51 onWindowStageDestroy() { 52 hilog.info(0x0000, 'testTag EntryAbility', '%{public}s', 'TestAbility onWindowStageDestroy'); 53 } 54 55 onForeground() { 56 hilog.info(0x0000, 'testTag EntryAbility', '%{public}s', 'TestAbility onForeground'); 57 } 58 59 onBackground() { 60 hilog.info(0x0000, 'testTag EntryAbility', '%{public}s', 'TestAbility onBackground'); 61 } 62}