LifecycleApp接口切换

FA模型接口 Stage模型接口对应d.ts文件 Stage模型对应接口
onShow?(): void; @ohos.window.d.ts on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType>): void;
监听FOREGROUND切到前台状态
onHide?(): void; @ohos.window.d.ts on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType>): void;
监听BACKGROUND切到后台状态
onDestroy?(): void; @ohos.app.ability.UIAbility.d.ts onDestroy(): void;
onCreate?(): void; @ohos.app.ability.UIAbility.d.ts onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void;
onWindowDisplayModeChanged?(isShownInMultiWindow: boolean, newConfig: resourceManager.Configuration): void; Stage模型无对应接口 暂时未提供对应接口
onStartContinuation?(): boolean; Stage模型无对应接口 Stage模型上,应用无需感知迁移是否成功(由应用发起迁移请求时感知),onStartContinuation废弃
onSaveData?(data: Object): boolean; @ohos.app.ability.UIAbility.d.ts onContinue(wantParam: Record<string, Object>): AbilityConstant.OnContinueResult;
onCompleteContinuation?(result: number): void; application\ContinueCallback.d.ts onContinueDone(result: number): void;
onRestoreData?(data: Object): void; @ohos.app.ability.UIAbility.d.ts onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void;
onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void;
多实例模式Ability迁移目标端在onCreate回调中完成数据恢复,单实例模式应用迁移目标端在onCreate回调中完成数据恢复,回调中通过判断launchParam.launchReason可获取迁移启动的场景,从而可以从Want中获取迁移前保存的数据
onRemoteTerminated?(): void; application\ContinueCallback.d.ts onContinueDone(result: number): void;
onSaveAbilityState?(outState: PacMap): void; @ohos.app.ability.UIAbility.d.ts onSaveState(reason: AbilityConstant.StateType, wantParam : Record<string, Object>): AbilityConstant.OnSaveResult;
onRestoreAbilityState?(inState: PacMap): void; @ohos.app.ability.UIAbility.d.ts onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void;
应用重启后会触发Ability的onCreate方法,通过判断launchParam.launchReason可获取自恢复的场景,从而可以从Want中获取重启前保存的数据
onInactive?(): void; @ohos.app.ability.UIAbility.d.ts onBackground(): void;
onActive?(): void; @ohos.app.ability.UIAbility.d.ts onForeground(): void;
onNewWant?(want: Want): void; @ohos.app.ability.UIAbility.d.ts onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void;
onMemoryLevel?(level: number): void @ohos.app.ability.UIAbility.d.ts onMemoryLevel(level: AbilityConstant.MemoryLevel): void;