@@ -4,7 +4,7 @@ The **appRecovery** module provides APIs for recovering faulty applications.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. In the current version, only applications with a single ability in a single process can be recovered.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. In API version 9, only applications with a single ability in a process can be recovered. In API version 10, applications with multiple abilities in a process can be recovered.
## Modules to Import
```ts
...
...
@@ -51,7 +51,7 @@ Enumerates the application state saving modes. This enum is used as an input par
Enables application recovery. After this API is called, the first ability that is displayed when the application is started from the initiator can be restored.
| saveOccasion | [SaveOccasionFlag](#apprecoverysaveoccasionflag) | No| Scenario for saving the application state. By default, the state is saved when a fault occurs.|
| saveMode | [SaveModeFlag](#apprecoverysavemodeflag) | No| Application state saving mode. By default, the application state is written to the local file cache.|
Restarts the application. This API can be used together with APIs of [errorManager](js-apis-app-ability-errorManager.md).
Restarts the current process and starts the first ability that is displayed when the application is started. If the state of this ability is saved, the saved state data is passed into the **wantParam** attribute in the **want** parameter of the **OnCreate** lifecycle callback of the ability.
In API version 10, the ability specified by [setRestartWant](#apprecoverysetrestartwant) is started. If no ability is specified, the following rules are used:
- If the ability of the current application running in the foreground supports recovery, that ability is started.
- If multiple abilities that support recovery is running in the foreground, only the last ability is started.
- If no ability is running in the foreground, none of them is started.
This API can be used together with the APIs of [errorManager](js-apis-app-ability-errorManager.md).
@@ -123,8 +132,8 @@ Saves the application state. This API can be used together with APIs of [errorMa
| -------- | -------- |
| boolean | Whether the application state is saved. The value **true** is returned if the application state is saved, and **false** is returned otherwise.|
Saves the ability state, which will be used for recovery. This API can be used together with the APIs of [errorManager](js-apis-app-ability-errorManager.md).
| boolean | Whether the application state is saved. The value **true** is returned if the application state is saved, and **false** is returned otherwise.|
## Added the saveAppState API to cl.ability.appRecovery
The API **saveAppState (context?: UIAbilityContext): boolean;** is added.
**Change Impact**
When developing an application based on OpenHarmony 4.0.5.2 or a later SDK version, you can use **saveAppState** with the ability context specified to save the state of the specified ability.
**Key API/Component Changes**
The **saveAppState** API is added to the **@ohos.app.ability.appRecovery.d.ts** file.