From d870a48c07d7165ad7df547ba6262300d184dd47 Mon Sep 17 00:00:00 2001 From: zhang_hao_zheng Date: Fri, 18 Jul 2025 17:18:59 +0800 Subject: [PATCH 1/8] =?UTF-8?q?abilityLifecycleCallback=E7=9B=B8=E5=85=B3s?= =?UTF-8?q?dk=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhang_hao_zheng Change-Id: I8961e3b7875dbaed9353782915cc157d638711fb --- ....app.ability.AbilityLifecycleCallback.d.ts | 21 ++++-- api/application/ApplicationContext.d.ts | 67 +++++++++++++++++++ 2 files changed, 81 insertions(+), 7 deletions(-) diff --git a/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts b/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts index d7351fe229..4ca22a44fe 100644 --- a/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts +++ b/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts @@ -44,7 +44,8 @@ import window from './@ohos.window'; * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ export default class AbilityLifecycleCallback { /** @@ -72,7 +73,8 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ onAbilityCreate(ability: UIAbility): void; @@ -115,7 +117,8 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void; @@ -223,7 +226,8 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void; @@ -264,7 +268,8 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ onAbilityDestroy(ability: UIAbility): void; @@ -304,7 +309,8 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ onAbilityForeground(ability: UIAbility): void; @@ -344,7 +350,8 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ onAbilityBackground(ability: UIAbility): void; diff --git a/api/application/ApplicationContext.d.ts b/api/application/ApplicationContext.d.ts index cd4f9a46f1..2b4be0d609 100644 --- a/api/application/ApplicationContext.d.ts +++ b/api/application/ApplicationContext.d.ts @@ -103,6 +103,28 @@ declare class ApplicationContext extends Context { */ on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback): number; + /** + * Registers a listener to monitor the ability lifecycle of the application. + * This API uses an asynchronous callback to return the result. + * + *

**NOTE**: + *
It can be called only by the main thread. + *

+ * + * @param { 'abilityLifecycle' } type - Event type. + * @param { AbilityLifecycleCallback } callback - Callback used to return the ID of the registered listener. + * @returns { double } Returns the number code of the callback. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback): double; + /** * Unregister ability lifecycle callback. * @@ -148,6 +170,29 @@ declare class ApplicationContext extends Context { */ off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback): void; + /** + * Unregisters the listener that monitors the ability lifecycle of the application. + * This API uses an asynchronous callback to return the result. + * + *

**NOTE**: + *
It can be called only by the main thread. + *

+ * + * @param { 'abilityLifecycle' } type - Event type. + * @param { double } callbackId - ID of the listener to unregister. + * @param { AsyncCallback } callback - Callback used to return the result. If the deregistration is successful, + * err is undefined. Otherwise, err is an error object. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + off(type: 'abilityLifecycle', callbackId: double, callback: AsyncCallback): void; + /** * Unregister ability lifecycle callback. * @@ -192,6 +237,28 @@ declare class ApplicationContext extends Context { */ off(type: 'abilityLifecycle', callbackId: number): Promise; + /** + * Unregisters the listener that monitors the ability lifecycle of the application. + * This API uses a promise to return the result. + * + *

**NOTE**: + *
It can be called only by the main thread. + *

+ * + * @param { 'abilityLifecycle' } type - Event type. + * @param { double } callbackId - ID of the listener to unregister. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + off(type: 'abilityLifecycle', callbackId: double): Promise; + /** * Register environment callback. * -- Gitee From e471ae00a1a5f5625ccad67a710cf7ed5392d180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8A=E5=B3=A5?= Date: Mon, 21 Jul 2025 03:44:15 +0000 Subject: [PATCH 2/8] update api/application/ApplicationContext.d.ts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张昊峥 --- api/application/ApplicationContext.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/application/ApplicationContext.d.ts b/api/application/ApplicationContext.d.ts index 2b4be0d609..e821992f81 100644 --- a/api/application/ApplicationContext.d.ts +++ b/api/application/ApplicationContext.d.ts @@ -113,7 +113,7 @@ declare class ApplicationContext extends Context { * * @param { 'abilityLifecycle' } type - Event type. * @param { AbilityLifecycleCallback } callback - Callback used to return the ID of the registered listener. - * @returns { double } Returns the number code of the callback. + * @returns { int } Returns the number code of the callback. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. * 2.Incorrect parameter types. * @syscap SystemCapability.Ability.AbilityRuntime.Core @@ -123,7 +123,7 @@ declare class ApplicationContext extends Context { * @since 20 * @arkts 1.2 */ - on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback): double; + on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback): int; /** * Unregister ability lifecycle callback. @@ -179,7 +179,7 @@ declare class ApplicationContext extends Context { *

* * @param { 'abilityLifecycle' } type - Event type. - * @param { double } callbackId - ID of the listener to unregister. + * @param { int } callbackId - ID of the listener to unregister. * @param { AsyncCallback } callback - Callback used to return the result. If the deregistration is successful, * err is undefined. Otherwise, err is an error object. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. @@ -191,7 +191,7 @@ declare class ApplicationContext extends Context { * @since 20 * @arkts 1.2 */ - off(type: 'abilityLifecycle', callbackId: double, callback: AsyncCallback): void; + off(type: 'abilityLifecycle', callbackId: int, callback: AsyncCallback): void; /** * Unregister ability lifecycle callback. @@ -246,7 +246,7 @@ declare class ApplicationContext extends Context { *

* * @param { 'abilityLifecycle' } type - Event type. - * @param { double } callbackId - ID of the listener to unregister. + * @param { int } callbackId - ID of the listener to unregister. * @returns { Promise } Promise that returns no value. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. * 2.Incorrect parameter types. @@ -257,7 +257,7 @@ declare class ApplicationContext extends Context { * @since 20 * @arkts 1.2 */ - off(type: 'abilityLifecycle', callbackId: double): Promise; + off(type: 'abilityLifecycle', callbackId: int): Promise; /** * Register environment callback. -- Gitee From e965548b5f622f4cf0f9ebe239d7095900ae2271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8A=E5=B3=A5?= Date: Mon, 21 Jul 2025 06:53:00 +0000 Subject: [PATCH 3/8] update api/application/ApplicationContext.d.ts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张昊峥 --- api/application/ApplicationContext.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/api/application/ApplicationContext.d.ts b/api/application/ApplicationContext.d.ts index e821992f81..462c1a7164 100644 --- a/api/application/ApplicationContext.d.ts +++ b/api/application/ApplicationContext.d.ts @@ -25,9 +25,7 @@ import type ConfigurationConstant from '../@ohos.app.ability.ConfigurationConsta import Want from '../@ohos.app.ability.Want'; import EnvironmentCallback from '../@ohos.app.ability.EnvironmentCallback'; import type ApplicationStateChangeCallback from '../@ohos.app.ability.ApplicationStateChangeCallback'; -/*** if arkts 1.1 */ import AbilityLifecycleCallback from '../@ohos.app.ability.AbilityLifecycleCallback'; -/*** endif */ /** * The context of an application. It allows access to application-specific resources. -- Gitee From 0179c6dbea532880c74b50819fdb5b9ce311bc52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8A=E5=B3=A5?= Date: Mon, 21 Jul 2025 07:13:39 +0000 Subject: [PATCH 4/8] update api/application/ApplicationContext.d.ts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张昊峥 --- api/application/ApplicationContext.d.ts | 76 ++----------------------- 1 file changed, 6 insertions(+), 70 deletions(-) diff --git a/api/application/ApplicationContext.d.ts b/api/application/ApplicationContext.d.ts index 462c1a7164..12a06466b5 100644 --- a/api/application/ApplicationContext.d.ts +++ b/api/application/ApplicationContext.d.ts @@ -90,27 +90,6 @@ declare class ApplicationContext extends Context { * * @param { 'abilityLifecycle' } type - Event type. * @param { AbilityLifecycleCallback } callback - Callback used to return the ID of the registered listener. - * @returns { number } Returns the number code of the callback. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. - * 2.Incorrect parameter types. - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @stagemodelonly - * @crossplatform - * @atomicservice - * @since 11 - */ - on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback): number; - - /** - * Registers a listener to monitor the ability lifecycle of the application. - * This API uses an asynchronous callback to return the result. - * - *

**NOTE**: - *
It can be called only by the main thread. - *

- * - * @param { 'abilityLifecycle' } type - Event type. - * @param { AbilityLifecycleCallback } callback - Callback used to return the ID of the registered listener. * @returns { int } Returns the number code of the callback. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. * 2.Incorrect parameter types. @@ -118,8 +97,8 @@ declare class ApplicationContext extends Context { * @stagemodelonly * @crossplatform * @atomicservice - * @since 20 - * @arkts 1.2 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback): int; @@ -164,30 +143,8 @@ declare class ApplicationContext extends Context { * @stagemodelonly * @crossplatform * @atomicservice - * @since 11 - */ - off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback): void; - - /** - * Unregisters the listener that monitors the ability lifecycle of the application. - * This API uses an asynchronous callback to return the result. - * - *

**NOTE**: - *
It can be called only by the main thread. - *

- * - * @param { 'abilityLifecycle' } type - Event type. - * @param { int } callbackId - ID of the listener to unregister. - * @param { AsyncCallback } callback - Callback used to return the result. If the deregistration is successful, - * err is undefined. Otherwise, err is an error object. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. - * 2.Incorrect parameter types. - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @stagemodelonly - * @crossplatform - * @atomicservice - * @since 20 - * @arkts 1.2 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ off(type: 'abilityLifecycle', callbackId: int, callback: AsyncCallback): void; @@ -231,29 +188,8 @@ declare class ApplicationContext extends Context { * @stagemodelonly * @crossplatform * @atomicservice - * @since 12 - */ - off(type: 'abilityLifecycle', callbackId: number): Promise; - - /** - * Unregisters the listener that monitors the ability lifecycle of the application. - * This API uses a promise to return the result. - * - *

**NOTE**: - *
It can be called only by the main thread. - *

- * - * @param { 'abilityLifecycle' } type - Event type. - * @param { int } callbackId - ID of the listener to unregister. - * @returns { Promise } Promise that returns no value. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. - * 2.Incorrect parameter types. - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @stagemodelonly - * @crossplatform - * @atomicservice - * @since 20 - * @arkts 1.2 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ off(type: 'abilityLifecycle', callbackId: int): Promise; -- Gitee From 52355b70742d86bcae9d0e92690d1d4c2b7be122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8A=E5=B3=A5?= Date: Mon, 21 Jul 2025 07:56:54 +0000 Subject: [PATCH 5/8] update api/application/ApplicationContext.d.ts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张昊峥 --- api/application/ApplicationContext.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/application/ApplicationContext.d.ts b/api/application/ApplicationContext.d.ts index 12a06466b5..f60677120b 100644 --- a/api/application/ApplicationContext.d.ts +++ b/api/application/ApplicationContext.d.ts @@ -134,7 +134,7 @@ declare class ApplicationContext extends Context { *

* * @param { 'abilityLifecycle' } type - Event type. - * @param { number } callbackId - ID of the listener to unregister. + * @param { int } callbackId - ID of the listener to unregister. * @param { AsyncCallback } callback - Callback used to return the result. If the deregistration is successful, * err is undefined. Otherwise, err is an error object. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. @@ -180,7 +180,7 @@ declare class ApplicationContext extends Context { *

* * @param { 'abilityLifecycle' } type - Event type. - * @param { number } callbackId - ID of the listener to unregister. + * @param { int } callbackId - ID of the listener to unregister. * @returns { Promise } Promise that returns no value. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. * 2.Incorrect parameter types. -- Gitee From c83f72bb4592d7a553d71d192a446068361f0d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8A=E5=B3=A5?= Date: Mon, 21 Jul 2025 08:35:44 +0000 Subject: [PATCH 6/8] update api/@ohos.app.ability.AbilityLifecycleCallback.d.ts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张昊峥 --- ....app.ability.AbilityLifecycleCallback.d.ts | 98 ++++++++++++++++--- 1 file changed, 86 insertions(+), 12 deletions(-) diff --git a/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts b/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts index 4ca22a44fe..6c9d36a7e8 100644 --- a/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts +++ b/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts @@ -73,11 +73,23 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ onAbilityCreate(ability: UIAbility): void; + /** + * Called back when an ability is started for initialization. + * + * @param { UIAbility } ability - Indicates the ability to register for listening. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @StageModelOnly + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onAbilityCreate(ability: UIAbility): void {}; + /** * Called back before an ability is started for initialization. * @@ -117,11 +129,24 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void; + /** + * Called back when a window stage is created. + * + * @param { UIAbility } ability - Indicates the ability to register for listening. + * @param { window.WindowStage } windowStage - window stage to create + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @StageModelOnly + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void {}; + /** * Called back before a window stage is created. * @@ -226,11 +251,24 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void; + /** + * Called back when a window stage is destroyed. + * + * @param { UIAbility } ability - Indicates the ability to register for listening. + * @param { window.WindowStage } windowStage - window stage to destroy + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @StageModelOnly + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void {}; + /** * Called back before a window stage is destroyed. * @@ -268,11 +306,23 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ onAbilityDestroy(ability: UIAbility): void; + /** + * Called back when an ability is destroyed. + * + * @param { UIAbility } ability - Indicates the ability to register for listening. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @StageModelOnly + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onAbilityDestroy(ability: UIAbility): void {}; + /** * Called back before an ability is destroyed. * @@ -309,11 +359,23 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ onAbilityForeground(ability: UIAbility): void; + /** + * Called back when the state of an ability changes to foreground. + * + * @param { UIAbility } ability - Indicates the ability to register for listening. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @StageModelOnly + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onAbilityForeground(ability: UIAbility): void {}; + /** * Called back before the state of an ability changes to foreground. * @@ -350,11 +412,23 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ onAbilityBackground(ability: UIAbility): void; + /** + * Called back when the state of an ability changes to background. + * + * @param { UIAbility } ability - Indicates the ability to register for listening. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @StageModelOnly + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + onAbilityBackground(ability: UIAbility): void {}; + /** * Called back before the state of an ability changes to background. * -- Gitee From 7f5e35b87dfcd85cd68ccbe6c900d4d2c6fc21ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8A=E5=B3=A5?= Date: Mon, 21 Jul 2025 10:03:53 +0000 Subject: [PATCH 7/8] update api/@ohos.app.ability.AbilityLifecycleCallback.d.ts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张昊峥 --- ....app.ability.AbilityLifecycleCallback.d.ts | 117 +++++------------- 1 file changed, 29 insertions(+), 88 deletions(-) diff --git a/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts b/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts index 6c9d36a7e8..e5dee46a08 100644 --- a/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts +++ b/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts @@ -22,6 +22,7 @@ import UIAbility from './@ohos.app.ability.UIAbility'; import dataAbility from './@ohos.data.dataAbility'; import window from './@ohos.window'; +/*** if arkts 1.1 */ /** * The ability lifecycle callback. * @@ -44,10 +45,24 @@ import window from './@ohos.window'; * @StageModelOnly * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ export default class AbilityLifecycleCallback { +/*** endif */ + +/*** if arkts 1.2 */ +/** + * The ability lifecycle callback. + * + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @StageModelOnly + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ +declare interface AbilityLifecycleCallback { +/*** endif */ /** * Called back when an ability is started for initialization. * @@ -73,23 +88,11 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ onAbilityCreate(ability: UIAbility): void; - /** - * Called back when an ability is started for initialization. - * - * @param { UIAbility } ability - Indicates the ability to register for listening. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @StageModelOnly - * @crossplatform - * @atomicservice - * @since 20 - * @arkts 1.2 - */ - onAbilityCreate(ability: UIAbility): void {}; - /** * Called back before an ability is started for initialization. * @@ -129,24 +132,11 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void; - /** - * Called back when a window stage is created. - * - * @param { UIAbility } ability - Indicates the ability to register for listening. - * @param { window.WindowStage } windowStage - window stage to create - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @StageModelOnly - * @crossplatform - * @atomicservice - * @since 20 - * @arkts 1.2 - */ - onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void {}; - /** * Called back before a window stage is created. * @@ -251,24 +241,11 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void; - /** - * Called back when a window stage is destroyed. - * - * @param { UIAbility } ability - Indicates the ability to register for listening. - * @param { window.WindowStage } windowStage - window stage to destroy - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @StageModelOnly - * @crossplatform - * @atomicservice - * @since 20 - * @arkts 1.2 - */ - onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void {}; - /** * Called back before a window stage is destroyed. * @@ -306,23 +283,11 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ onAbilityDestroy(ability: UIAbility): void; - /** - * Called back when an ability is destroyed. - * - * @param { UIAbility } ability - Indicates the ability to register for listening. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @StageModelOnly - * @crossplatform - * @atomicservice - * @since 20 - * @arkts 1.2 - */ - onAbilityDestroy(ability: UIAbility): void {}; - /** * Called back before an ability is destroyed. * @@ -359,23 +324,11 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ onAbilityForeground(ability: UIAbility): void; - /** - * Called back when the state of an ability changes to foreground. - * - * @param { UIAbility } ability - Indicates the ability to register for listening. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @StageModelOnly - * @crossplatform - * @atomicservice - * @since 20 - * @arkts 1.2 - */ - onAbilityForeground(ability: UIAbility): void {}; - /** * Called back before the state of an ability changes to foreground. * @@ -412,23 +365,11 @@ export default class AbilityLifecycleCallback { * @StageModelOnly * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ onAbilityBackground(ability: UIAbility): void; - /** - * Called back when the state of an ability changes to background. - * - * @param { UIAbility } ability - Indicates the ability to register for listening. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @StageModelOnly - * @crossplatform - * @atomicservice - * @since 20 - * @arkts 1.2 - */ - onAbilityBackground(ability: UIAbility): void {}; - /** * Called back before the state of an ability changes to background. * -- Gitee From cb7bd47050ada223520f6cb173b4d230da2f1de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8A=E5=B3=A5?= Date: Mon, 21 Jul 2025 10:54:48 +0000 Subject: [PATCH 8/8] update api/@ohos.app.ability.AbilityLifecycleCallback.d.ts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张昊峥 --- api/@ohos.app.ability.AbilityLifecycleCallback.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts b/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts index e5dee46a08..efb952ea53 100644 --- a/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts +++ b/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts @@ -457,3 +457,7 @@ declare interface AbilityLifecycleCallback { */ onAbilitySaveState?(ability: UIAbility): void; } + +/*** if arkts 1.2 */ +export default AbilityLifecycleCallback; +/*** endif */ \ No newline at end of file -- Gitee