1import Ability from '@ohos.app.ability.UIAbility' 2import LogUtils from '../common/utils/LogUtils' 3import CallManager from '../model/CallManager' 4import GlobalThisHelper from '../common/utils/GlobalThisHelper' 5import Constants from '../common/utils/Constants' 6 7const TAG = "MainAbility"; 8 9export default class MainAbility extends Ability { 10 onCreate(want, launchParam) { 11 LogUtils.i(TAG, "onCreate") 12 GlobalThisHelper.set<any>(Constants.GLOBALTHIS_ABILITY_WANT, want); 13 GlobalThisHelper.set<any>(Constants.GLOBALTHIS_CONTEXT, this.context); 14 } 15 16 onWindowStageCreate(windowStage) { 17 // Main window is created, set main page for this ability 18 LogUtils.i(TAG, "onWindowStageCreate") 19 windowStage.setShowOnLockScreen(true); 20 windowStage.loadContent("pages/index", (err, data) => { 21 if (err.code) { 22 LogUtils.e(TAG, 'Failed to load the content. Cause:' + JSON.stringify(err)); 23 return; 24 } 25 LogUtils.e(TAG, 'Succeeded in loading the content. Data: ' + JSON.stringify(data)) 26 }); 27 } 28 29 onWindowStageDestroy() { 30 // Main window is destroyed, release UI related resources 31 LogUtils.i(TAG, "onWindowStageDestroy") 32 } 33 34 onForeground() { 35 // Ability has brought to foreground 36 LogUtils.i(TAG, "onForeground") 37 } 38 39 onBackground() { 40 // Ability has back to background 41 LogUtils.i(TAG, "onBackground") 42 } 43 44 onDestroy() { 45 LogUtils.i(TAG, "onDestroy") 46 CallManager.getInstance()?.clearTimer(); 47 } 48}; 49