1e41f4b71Sopenharmony_ci# @ohos.application.abilityManager (AbilityManager) (System API) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **AbilityManager** module provides APIs for obtaining, adding, and modifying ability running information and state information. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.abilityManager](js-apis-app-ability-abilityManager-sys.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci> The APIs of this module are system APIs and cannot be called by third-party applications. 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## Modules to Import 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci```ts 13e41f4b71Sopenharmony_ciimport abilityManager from '@ohos.application.abilityManager'; 14e41f4b71Sopenharmony_ci``` 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci## AbilityState 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ciEnumerates the ability states. 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci**System API**: This is a system API. 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci| Name| Value| Description| 25e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 26e41f4b71Sopenharmony_ci| INITIAL | 0 | The ability is in the initial state.| 27e41f4b71Sopenharmony_ci| FOREGROUND | 9 | The ability is running in the foreground. | 28e41f4b71Sopenharmony_ci| BACKGROUND | 10 | The ability is running in the background. | 29e41f4b71Sopenharmony_ci| FOREGROUNDING | 11 | The ability is being switched to the foreground. | 30e41f4b71Sopenharmony_ci| BACKGROUNDING | 12 | The ability is being switched to the background. | 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci## updateConfiguration 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ciupdateConfiguration(config: Configuration, callback: AsyncCallback\<void>): void 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ciUpdates the configuration. This API uses an asynchronous callback to return the result. 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci**Permission required**: ohos.permission.UPDATE_CONFIGURATION 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci**Parameters** 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 45e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- | 46e41f4b71Sopenharmony_ci| config | [Configuration](js-apis-application-configuration.md) | Yes | New configuration.| 47e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the configuration is updated, **err** is undefined; otherwise, **err** is an error object. | 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci**Example** 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci```ts 52e41f4b71Sopenharmony_ciimport abilityManager from '@ohos.application.abilityManager'; 53e41f4b71Sopenharmony_ciimport { Configuration } from '@ohos.application.Configuration'; 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_cilet config: Configuration = { 56e41f4b71Sopenharmony_ci language: 'chinese' 57e41f4b71Sopenharmony_ci}; 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ciabilityManager.updateConfiguration(config, () => { 60e41f4b71Sopenharmony_ci console.log('------------ updateConfiguration -----------'); 61e41f4b71Sopenharmony_ci}); 62e41f4b71Sopenharmony_ci``` 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci## updateConfiguration 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ciupdateConfiguration(config: Configuration): Promise\<void> 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ciUpdates the configuration. This API uses a promise to return the result. 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci**Permission required**: ohos.permission.UPDATE_CONFIGURATION 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci**System API**: This is a system API. 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci**Parameters** 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 79e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- | 80e41f4b71Sopenharmony_ci| config | [Configuration](js-apis-application-configuration.md) | Yes | New configuration.| 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci**Return value** 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci| Type | Description | 85e41f4b71Sopenharmony_ci| ---------------------------------------- | ------- | 86e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value.| 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci**Example** 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci```ts 91e41f4b71Sopenharmony_ciimport abilityManager from '@ohos.application.abilityManager'; 92e41f4b71Sopenharmony_ciimport { Configuration } from '@ohos.application.Configuration'; 93e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base'; 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_cilet config: Configuration = { 96e41f4b71Sopenharmony_ci language: 'chinese' 97e41f4b71Sopenharmony_ci}; 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ciabilityManager.updateConfiguration(config).then(() => { 100e41f4b71Sopenharmony_ci console.log('updateConfiguration success'); 101e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 102e41f4b71Sopenharmony_ci console.error('updateConfiguration fail'); 103e41f4b71Sopenharmony_ci}); 104e41f4b71Sopenharmony_ci``` 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci## getAbilityRunningInfos 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_cigetAbilityRunningInfos(callback: AsyncCallback\<Array\<AbilityRunningInfo>>): void 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ciObtains the ability running information. This API uses an asynchronous callback to return the result. 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_RUNNING_INFO 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci**System API**: This is a system API. 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci**Parameters** 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 121e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- | 122e41f4b71Sopenharmony_ci| callback | AsyncCallback\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo-sys.md)>> | Yes | Callback used to return the ability running information. | 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci**Example** 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ci```ts 127e41f4b71Sopenharmony_ciimport abilityManager from '@ohos.application.abilityManager'; 128e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base'; 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ciabilityManager.getAbilityRunningInfos((err: BusinessError, data) => { 131e41f4b71Sopenharmony_ci console.log(`getAbilityRunningInfos err: ${err}, data: ${JSON.stringify(data)}`); 132e41f4b71Sopenharmony_ci}); 133e41f4b71Sopenharmony_ci``` 134e41f4b71Sopenharmony_ci 135e41f4b71Sopenharmony_ci## getAbilityRunningInfos 136e41f4b71Sopenharmony_ci 137e41f4b71Sopenharmony_cigetAbilityRunningInfos(): Promise\<Array\<AbilityRunningInfo>> 138e41f4b71Sopenharmony_ci 139e41f4b71Sopenharmony_ciObtains the ability running information. This API uses a promise to return the result. 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_RUNNING_INFO 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci**System API**: This is a system API. 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci**Return value** 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ci| Type | Description | 150e41f4b71Sopenharmony_ci| ---------------------------------------- | ------- | 151e41f4b71Sopenharmony_ci| Promise\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo-sys.md)>> | Promise used to return the ability running information.| 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_ci**Example** 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci```ts 156e41f4b71Sopenharmony_ciimport abilityManager from '@ohos.application.abilityManager'; 157e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base'; 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_ciabilityManager.getAbilityRunningInfos().then((data) => { 160e41f4b71Sopenharmony_ci console.log(`getAbilityRunningInfos data: ${JSON.stringify(data)}`); 161e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 162e41f4b71Sopenharmony_ci console.error(`getAbilityRunningInfos err: ${JSON.stringify(err)}`); 163e41f4b71Sopenharmony_ci}); 164e41f4b71Sopenharmony_ci``` 165