提交 0ea287c7 编写于 作者: 杨亮

IssueNo: #I5AUBR

Description: 提供创建不同Hap包上下文能力
Sig: SIG_ApplicationFramework
Feature or Bugfix: Feature
Binary Source: No
Signed-off-by: N杨亮 <yangliang36@huawei.com>
Change-Id: Icea661ec289d76d41458ec3ddbd3236689f9e1c1
上级 f403cb41
......@@ -68,6 +68,76 @@ createBundleContext(bundleName: string): Context;
```
## Context.createModuleContext
createModuleContext(moduleName: string): Context;
创建指定hap上下文。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| moduleName | string | 是 | 应用内hap名。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Context | 对应创建hap的上下文context。 |
**示例:**
```js
import AbilityContext from '@ohos.application.Ability'
class MainAbility extends AbilityContext {
onWindowStageCreate(windowStage) {
let moduleName = "module";
let context = this.context.createModuleContext(moduleName);
}
}
```
## Context.createModuleContext
createModuleContext(bundleName: string, moduleName: string): Context;
创建指定应用上下文。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| bundleName | string | 是 | 应用bundle名。 |
| moduleName | string | 是 | 应用内hap名。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Context | 对应创建应用内hap的上下文context。 |
**示例:**
```js
import AbilityContext from '@ohos.application.Ability'
class MainAbility extends AbilityContext {
onWindowStageCreate(windowStage) {
let bundleName = "com.example.bundle";
let moduleName = "module";
let context = this.context.createModuleContext(bundleName, moduleName);
}
}
```
## Context.getApplicationContext
getApplicationContext(): ApplicationContext;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册