• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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 Ability from '@ohos.app.ability.UIAbility';
17import type Window from '@ohos.window';
18import LogUtils from '../common/utils/LogUtils';
19import { Context } from '@ohos.abilityAccessCtrl';
20
21const TAG = 'MainAbility';
22
23export default class MainAbility extends Ability {
24  onCreate(want, launchParam): void {
25    LogUtils.i(TAG, 'onCreate');
26    globalThis.settingsAbilityContext = this.context;
27	AppStorage.setOrCreate<Context>('abilityContext',this.context)
28    AppStorage.setOrCreate<boolean>('ApnStatus',false)
29  }
30
31  onDestroy(): void {
32    LogUtils.i(TAG, 'onDestroy!');
33  }
34
35  onWindowStageCreate(windowStage: Window.WindowStage): void {
36    // Main window is created, set main page for this ability
37    LogUtils.i(TAG, 'onWindowStageCreate!');
38
39    windowStage.loadContent('pages/index', (err, data) => {
40      if (err.code) {
41        LogUtils.e(TAG, 'Failed to load the content. Cause: ' + JSON.stringify(err));
42        return;
43      }
44      LogUtils.i(TAG, 'Succeeded in loading the content. Data: ' + JSON.stringify(data));
45    });
46  }
47
48  onWindowStageDestroy(): void {
49    // Main window is destroyed, release UI related resources
50    LogUtils.i(TAG, 'onWindowStageDestroy!');
51  }
52
53  onForeground(): void {
54    // Ability has brought to foreground
55    LogUtils.i(TAG, 'onForeground!');
56  }
57
58  onBackground(): void {
59    // Ability has back to background
60    LogUtils.i(TAG, 'onBackground!');
61  }
62}
63