harmony 鸿蒙LifecycleApp Switching

  • 2023-02-03
  • 浏览 (804)

LifecycleApp Switching

API in the FA Model Corresponding .d.ts File in the Stage Model Corresponding API in the Stage Model
onShow?(): void; \@ohos.window.d.ts on(eventType: ‘windowStageEvent’, callback: Callback<WindowStageEventType>): void;
Listens for SHOWN, indicating a switching to the foreground.
onHide?(): void; \@ohos.window.d.ts on(eventType: ‘windowStageEvent’, callback: Callback<WindowStageEventType>): void;
Listens for HIDDEN, indicating a switching to the 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; There is no corresponding API in the stage model. No corresponding API is provided.
onStartContinuation?(): boolean; There is no corresponding API in the stage model. In the stage model, an application does not need to detect whether the continuation is successful (detected when the application initiates the continuation request). Therefore, the onStartContinuation() callback is deprecated.
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;
In multiton or singleton mode, the target ability completes data restoration in the onCreate() callback. In the callback, launchParam.launchReason is used to determine whether it is a continuation-based launch scenario. If it is, the data saved before continuation can be obtained from the want parameter.
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;
After an application is restarted, the onCreate() callback is triggered. In the callback, launchParam.launchReason is used to determine whether it is a self-recovery scenario. If it is, the data saved before the restart can be obtained from the want parameter.
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;

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Ability Kit

harmony 鸿蒙Obtaining Reasons for Abnormal Application Exits

harmony 鸿蒙UIAbility Backup and Restore

harmony 鸿蒙Using Explicit Want to Start an Application Component

harmony 鸿蒙Introduction to Ability Kit

harmony 鸿蒙AbilityStage Component Container

harmony 鸿蒙Accessing a DataAbility

harmony 鸿蒙Accessing a DataShareExtensionAbility from the FA Model

harmony 鸿蒙Common action and entities Values (Not Recommended)

harmony 鸿蒙API Switching Overview

0  赞