• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import Ability from '@ohos.app.ability.UIAbility'
2import Window from '@ohos.window'
3
4import HiLog from "../utils/HiLog";
5import MmsPreferences from "../utils/MmsPreferences";
6import MmsDatabaseHelper from "../utils/MmsDatabaseHelper";
7import WantUtil from "../utils/WantUtil";
8import simCardService from "../service/SimCardService";
9
10const TAG = "app";
11
12export default class MainAbility extends Ability {
13    onCreate(want, launchParam) {
14        HiLog.i(TAG, "Ability onCreate com.ohos.mms version: 1.0.0.40");
15        globalThis.mmsContext = this.context;
16        globalThis.abilityWant = want;
17        globalThis.MmsDatabaseHelper = new MmsDatabaseHelper();
18        globalThis.MmsDatabaseHelper.createTable();
19        globalThis.needToUpdate = true;
20        MmsPreferences.getInstance().initPreferences();
21    }
22
23    onNewWant(want, launchParam) {
24        HiLog.i(TAG, 'Application onNewWant');
25        globalThis.abilityWant = want;
26    }
27
28    onWindowStageCreate(windowStage: Window.WindowStage) {
29        // Main window is created, set main page for this ability
30        windowStage.loadContent('pages/index', (err, data) => {
31            if (err.code) {
32                HiLog.e(TAG, 'testTag', 'Failed to load the content.');
33                return;
34            }
35            HiLog.i(TAG, 'testTag', 'Succeeded in loading the content. Data: %{public}s');
36        });
37    }
38
39    onWindowStageDestroy() {
40        // Main window is destroyed, release UI related resources
41        HiLog.i(TAG, 'Ability onWindowStageDestroy');
42    }
43
44    onForeground() {
45        // Ability has brought to foreground
46        HiLog.i(TAG, 'Ability onForeground');
47        simCardService.init();
48    }
49
50    onBackground() {
51        // Ability has back to background
52        HiLog.i(TAG, 'Ability onBackground');
53        simCardService.deInit();
54    }
55
56}
57