1# @ohos.app.ability.abilityManager (AbilityManager) 2 3The AbilityManager module provides APIs for obtaining ability information and running status information. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 14. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8 9## Modules to Import 10 11```ts 12import { abilityManager } from '@kit.AbilityKit'; 13``` 14 15 16## AbilityState 17 18Enumerates the ability states. This enum can be used together with [AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md) to return the ability state. 19 20**System capability**: SystemCapability.Ability.AbilityRuntime.Core 21 22| Name| Value| Description| 23| -------- | -------- | -------- | 24| INITIAL | 0 | The ability is in the initial state.| 25| FOCUS | 2 | The ability has the focus.| 26| FOREGROUND | 9 | The ability is in the foreground state. | 27| BACKGROUND | 10 | The ability is in the background state. | 28| FOREGROUNDING | 11 | The ability is in the state of being switched to the foreground. | 29| BACKGROUNDING | 12 | The ability is in the state of being switched to the background. | 30 31 32## getAbilityRunningInfos 33 34getAbilityRunningInfos(): Promise\<Array\<AbilityRunningInfo>> 35 36Obtains the UIAbility running information. This API uses a promise to return the result. 37 38**Required permissions**: ohos.permission.GET_RUNNING_INFO 39 40**System capability**: SystemCapability.Ability.AbilityRuntime.Core 41 42**Return value** 43 44| Type | Description | 45| ---------------------------------------- | ------- | 46| Promise\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)>> | Promise used to return the API call result and the UIAbility running information. You can perform error handling or custom processing in it.| 47 48**Error codes** 49 50For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 51 52| ID| Error Message| 53| ------- | -------- | 54| 16000050 | Internal error. | 55 56**Example** 57 58```ts 59import { abilityManager } from '@kit.AbilityKit'; 60import { BusinessError } from '@kit.BasicServicesKit'; 61 62try { 63 abilityManager.getAbilityRunningInfos().then((data: Array<abilityManager.AbilityRunningInfo>) => { 64 console.log(`getAbilityRunningInfos success, data: ${JSON.stringify(data)}`); 65 }).catch((err: BusinessError) => { 66 console.error(`getAbilityRunningInfos fail, err: ${JSON.stringify(err)}`); 67 }); 68} catch (paramError) { 69 let code: number = (paramError as BusinessError).code; 70 let message: string = (paramError as BusinessError).message; 71 console.error(`error.code: ${code}, error.message: ${message}`); 72} 73``` 74