1/** 2 * Copyright (c) 2024 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; 17import { hilog } from '@kit.PerformanceAnalysisKit'; 18import { window } from '@kit.ArkUI'; 19 20const domain = 0x0000; 21 22export default class StartTestAbility4 extends UIAbility { 23 public onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { 24 hilog.info(domain, 'testTag', '%{public}s', 'Ability onCreate'); 25 if (want.abilityName !== undefined) { 26 hilog.info(domain, launchParam.launchReason.toString(), '%{public}s', 'Ability onCreate'); 27 } 28 AppStorage.setOrCreate('bundleName',want.bundleName); 29 } 30 31 public onDestroy(): void { 32 hilog.info(domain, 'testTag', '%{public}s', 'Ability onDestroy'); 33 } 34 35 public onWindowStageCreate(windowStage: window.WindowStage): void { 36 // Main window is created, set main page for this ability 37 hilog.info(domain, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); 38 AppStorage.setOrCreate('windowStageStartTest4',windowStage); 39 AppStorage.setOrCreate('contextTest4', this.context) 40 } 41 42 public onWindowStageDestroy(): void { 43 // Main window is destroyed, release UI related resources 44 hilog.info(domain, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); 45 } 46 47 public onForeground(): void { 48 // Ability has brought to foreground 49 hilog.info(domain, 'testTag', '%{public}s', 'Ability onForeground'); 50 } 51 52 public onBackground(): void { 53 // Ability has back to background 54 hilog.info(domain, 'testTag', '%{public}s', 'Ability onBackground'); 55 } 56}