• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AbilityStageContext
2
3The AbilityStageContext module implements the context of an ability stage. It inherits from [Context](js-apis-inner-application-context.md).
4
5This module provides APIs for accessing a specific ability stage. You can use the APIs to obtain the ModuleInfo object and environment configuration of an ability stage.
6
7> **NOTE**
8>
9> 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.
10> The APIs of this module can be used only in the stage model.
11
12## Modules to Import
13
14```ts
15import { common } from '@kit.AbilityKit';
16```
17
18## Properties
19
20**Atomic service API**: This API can be used in atomic services since API version 11.
21
22**System capability**: SystemCapability.Ability.AbilityRuntime.Core
23
24| Name| Type| Read-Only| Optional| Description|
25| -------- | -------- | -------- | -------- | -------- |
26| currentHapModuleInfo | [HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md) | No| No| ModuleInfo object corresponding to the ability stage.|
27| config | [Configuration](js-apis-app-ability-configuration.md) | No| No| Environment variables.|
28
29**Example**
30
31```ts
32import { AbilityStage } from '@kit.AbilityKit';
33
34class MyAbilityStage extends AbilityStage {
35  onCreate() {
36    let abilityStageContext = this.context;
37    // Obtain the current module name.
38    let name = abilityStageContext.currentHapModuleInfo.name;
39    // Obtain the current language.
40    let language = abilityStageContext.config.language;
41  }
42}
43```
44