• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# BaseContext
2
3BaseContext is an abstract class that specifies whether a child class Context is used for the stage model or FA model. It is the parent class for all types of Context.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```ts
12import { common } from '@kit.AbilityKit';
13```
14
15## Attributes
16
17**Atomic service API**: This API can be used in atomic services since API version 11.
18
19**System capability**: SystemCapability.Ability.AbilityRuntime.Core
20
21| Name      | Type  | Read-Only  | Optional  | Description     |
22| -------- | ------ | ---- | ---- | ------- |
23| stageMode | boolean | No   | No   | Whether the child class Context is used for the stage model.<br>**true**: used for the stage model.<br>**false**: used for the FA model.|
24
25**Example**
26
27Take the stage model as an example. You can access the **stageMode** field through UIAbilityContext.
28
29```ts
30import { UIAbility, AbilityConstant, Want } from '@kit.AbilityKit';
31
32class EntryAbility extends UIAbility {
33  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
34    // EntryAbility onCreate, isStageMode: true
35    console.info(`EntryAbility onCreate, isStageMode: ${this.context.stageMode}`);
36  }
37}
38```
39