• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# BaseContext
2
3**BaseContext** 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 '@ohos.app.ability.common';
13```
14
15## Attributes
16
17**System capability**: SystemCapability.Ability.AbilityRuntime.Core
18
19| Name      | Type  | Readable  | Writable  | Description     |
20| -------- | ------ | ---- | ---- | ------- |
21| stageMode | boolean | Yes   | Yes   | 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.|
22
23**Example**
24
25Take the stage model as an example. You can access the **stageMode** field through **UIAbilityContext**.
26
27```ts
28import UIAbility from '@ohos.app.ability.UIAbility';
29import AbilityConstant from '@ohos.app.ability.AbilityConstant';
30import Want from '@ohos.app.ability.Want';
31
32class EntryAbility extends UIAbility {
33    onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
34        // EntryAbility onCreate, isStageMode: true
35        console.log('EntryAbility onCreate, isStageMode: ${this.context.stageMode}');
36    }
37}
38```
39