提交 473bc686 编写于 作者: D donglin

doc optimize

Signed-off-by: Ndonglin <donglin9@huawei.com>
Change-Id: I29a634d8b0b31ede41d853660f31c84dbd9bc5ef
上级 28f2d6d5
......@@ -19,40 +19,40 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| launchReason | LaunchReason| 是 | 是 | 指示启动原因。 |
| lastExitReason | LastExitReason | 是 | 是 | 表示最后退出原因。 |
| launchReason | [LaunchReason](#abilityconstantlaunchreason)| 是 | 是 | 枚举类型,表示启动原因。 |
| lastExitReason | [LastExitReason](#abilityconstantlastexitreason) | 是 | 是 | 枚举类型,表示最后退出原因。 |
## AbilityConstant.LaunchReason
初次启动原因。
初次启动原因,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate)方法根据launchParam.launchReason的不同类型执行相应操作
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | 未知的状态。 |
| START_ABILITY | 1 | 启动能力。 |
| CALL | 2 | 呼叫。 |
| CONTINUATION | 3 | 继续。 |
| APP_RECOVERY | 4 | 状态恢复。 |
| UNKNOWN | 0 | 未知原因。 |
| START_ABILITY | 1 | 通过[startAbility](js-apis-ability-context.md#abilitycontextstartability)接口启动ability。 |
| CALL | 2 | 通过[startAbilityByCall](js-apis-ability-context.md#abilitycontextstartabilitybycall)接口启动ability。 |
| CONTINUATION | 3 | 跨端设备迁移启动ability。 |
| APP_RECOVERY | 4 | 设置应用恢复后,应用故障时自动恢复启动ability。 |
## AbilityConstant.LastExitReason
上次退出原因。
上次退出原因,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate)方法根据launchParam.lastExitReason的不同类型执行相应操作
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | 未知的状态。 |
| ABILITY_NOT_RESPONDING | 1 | 能力没有反应 |
| NORMAL | 2 | 正常的状态。 |
| UNKNOWN | 0 | 未知原因。 |
| ABILITY_NOT_RESPONDING | 1 | ability未响应。 |
| NORMAL | 2 | 正常退出。 |
## AbilityConstant.OnContinueResult
迁移结果。
迁移结果,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onContinue(wantParam)](js-apis-app-ability-uiAbility.md#uiabilityoncontinue)方法进完成相应的返回
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
......@@ -64,7 +64,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
## AbilityConstant.WindowMode
启动Ability时的窗口模式。
启动Ability时的窗口模式,该类型为枚举,可配合startAbility使用指定启动Ability的窗口模式
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
......@@ -78,7 +78,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
## AbilityConstant.MemoryLevel
内存级别。
内存级别,该类型为枚举,可配合[Ability](js-apis-app-ability-ability.md)[onMemoryLevel(level)](js-apis-app-ability-ability.md#abilityonmemorylevel)方法根据level执行不同内存级别的相应操作
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
......@@ -90,22 +90,22 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
## AbilityConstant.OnSaveResult
保存应用数据的结果。
保存应用数据的结果,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onSaveState(reason, wantParam)](js-apis-app-ability-uiAbility.md#uiabilityonsavestate)方法完成相应的返回
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| ALL_AGREE | 0 | 同意保存状态。 |
| ALL_AGREE | 0 | 总是同意保存状态。 |
| CONTINUATION_REJECT | 1 | 拒绝迁移保存状态。 |
| CONTINUATION_MISMATCH | 2 | 迁移不匹配。|
| RECOVERY_AGREE | 3 | 同意恢复保存状态。 |
| RECOVERY_REJECT | 4 | 拒绝恢复保存状态。|
| ALL_REJECT | 5 | 拒绝保存状态。|
| ALL_REJECT | 5 | 总是拒绝保存状态。|
## AbilityConstant.StateType
保存应用数据场景原因。
保存应用数据场景原因,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onSaveState(reason, wantParam)](js-apis-app-ability-uiAbility.md#uiabilityonsavestate)方法根据reason的不同类型执行相应操作
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
......
# @ohos.app.ability.abilityDelegatorRegistry (AbilityDelegatorRegistry)
AbilityDelegatorRegistry模块提供用于存储已注册的AbilityDelegator和AbilityDelegatorArgs对象的全局寄存器的能力,包括获取应用程序的AbilityDelegator对象、获取单元测试参数AbilityDelegatorArgs对象。
AbilityDelegatorRegistry模块提供用于存储已注册的[AbilityDelegator](js-apis-inner-application-abilityDelegator.md)[AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md)对象的全局寄存器的能力,包括获取应用程序的[AbilityDelegator](js-apis-inner-application-abilityDelegator.md)对象、获取单元测试参数[AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md)对象。
> **说明:**
>
......@@ -14,7 +14,7 @@ import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry
## AbilityLifecycleState
Ability生命周期状态。
Ability生命周期状态,该类型为枚举,可配合[AbilityDelegator](js-apis-inner-application-abilityDelegator.md)[getAbilityState(ability)](js-apis-inner-application-abilityDelegator.md#getabilitystate9)方法返回不同ability生命周期
**系统能力** :以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
......@@ -28,9 +28,9 @@ Ability生命周期状态。
## AbilityDelegatorRegistry.getAbilityDelegator
getAbilityDelegator(): AbilityDelegator
getAbilityDelegator(): [AbilityDelegator](js-apis-inner-application-abilityDelegator.md)
获取应用程序的AbilityDelegator对象
获取应用程序的[AbilityDelegator](js-apis-inner-application-abilityDelegator.md)对象。
**系统能力:** SystemCapability.Ability.AbilityRuntime.Core
......@@ -45,13 +45,21 @@ getAbilityDelegator(): AbilityDelegator
```ts
var abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let want = {
bundleName: "com.ohos.example",
abilityName: "MainAbility"
}
abilityDelegator.startAbility(want, (err, data)=>{
console.log("startAbility callback err: " + JSON.stringify(err) + " data: " + JSON.stringify(data));
})
```
## AbilityDelegatorRegistry.getArguments
getArguments(): AbilityDelegatorArgs
getArguments(): [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md)
获取单元测试参数AbilityDelegatorArgs对象
获取单元测试参数[AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md)对象。
**系统能力:** SystemCapability.Ability.AbilityRuntime.Core
......
# @ohos.app.ability.abilityLifecycleCallback (AbilityLifecycleCallback)
AbilityLifecycleCallback模块提供应用上下文ApplicationContext的生命周期监听方法的回调类的能力,包括onAbilityCreate、onWindowStageCreate、onWindowStageDestroy等方法。
AbilityLifecycleCallback模块提供应用上下文[ApplicationContext](js-apis-inner-application-applicationContext.md)的生命周期监听方法的回调类的能力,包括[onAbilityCreate](#abilitylifecyclecallbackonabilitycreate)[onWindowStageCreate](#abilitylifecyclecallbackonwindowstagecreate)[onWindowStageActive](#abilitylifecyclecallbackonwindowstageactive)[onWindowStageInactive](#abilitylifecyclecallbackonwindowstageinactive)[onWindowStageDestroy](#abilitylifecyclecallbackonwindowstagedestroy)[onAbilityDestroy](#abilitylifecyclecallbackonabilitydestroy)[onAbilityForeground](#abilitylifecyclecallbackonabilityforeground)[onAbilityBackground](#abilitylifecyclecallbackonabilitybackground)[onAbilityContinue](#abilitylifecyclecallbackonabilitycontinue)方法。
> **说明:**
>
......@@ -17,7 +17,7 @@ import AbilityLifecycleCallback from "@ohos.app.ability.AbilityLifecycleCallback
## AbilityLifecycleCallback.onAbilityCreate
onAbilityCreate(ability: UIAbility): void;
onAbilityCreate(ability: [UIAbility](js-apis-app-ability-uiAbility.md)): void;
注册监听应用上下文的生命周期后,在ability创建时触发回调。
......@@ -27,12 +27,12 @@ onAbilityCreate(ability: UIAbility): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md#Ability) | 是 | 当前Ability对象 |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | 是 | 当前Ability对象 |
## AbilityLifecycleCallback.onWindowStageCreate
onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void;
onWindowStageCreate(ability: [UIAbility](js-apis-app-ability-uiAbility.md), windowStage: [window.WindowStage](js-apis-window.md#windowstage9)): void;
注册监听应用上下文的生命周期后,在windowStage创建时触发回调。
......@@ -42,13 +42,13 @@ onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md#Ability) | 是 | 当前Ability对象 |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | 是 | 当前Ability对象 |
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | 是 | 当前WindowStage对象 |
## AbilityLifecycleCallback.onWindowStageActive
onWindowStageActive(ability: UIAbility, windowStage: window.WindowStage): void;
onWindowStageActive(ability: [UIAbility](js-apis-app-ability-uiAbility.md), windowStage: [window.WindowStage](js-apis-window.md#windowstage9)): void;
注册监听应用上下文的生命周期后,在windowStage获焦时触发回调。
......@@ -58,13 +58,13 @@ onWindowStageActive(ability: UIAbility, windowStage: window.WindowStage): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md#Ability) | 是 | 当前Ability对象 |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | 是 | 当前Ability对象 |
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | 是 | 当前WindowStage对象 |
## AbilityLifecycleCallback.onWindowStageInactive
onWindowStageInactive(ability: UIAbility, windowStage: window.WindowStage): void;
onWindowStageInactive(ability: [UIAbility](js-apis-app-ability-uiAbility.md), windowStage: [window.WindowStage](js-apis-window.md#windowstage9)): void;
注册监听应用上下文的生命周期后,在windowStage失焦时触发回调。
......@@ -74,13 +74,13 @@ onWindowStageInactive(ability: UIAbility, windowStage: window.WindowStage): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md#Ability) | 是 | 当前Ability对象 |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | 是 | 当前Ability对象 |
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | 是 | 当前WindowStage对象 |
## AbilityLifecycleCallback.onWindowStageDestroy
onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void;
onWindowStageDestroy(ability: [UIAbility](js-apis-app-ability-uiAbility.md), windowStage: [window.WindowStage](js-apis-window.md#windowstage9)): void;
注册监听应用上下文的生命周期后,在windowStage销毁时触发回调。
......@@ -90,13 +90,13 @@ onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md#Ability) | 是 | 当前Ability对象 |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | 是 | 当前Ability对象 |
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | 是 | 当前WindowStage对象 |
## AbilityLifecycleCallback.onAbilityDestroy
onAbilityDestroy(ability: UIAbility): void;
onAbilityDestroy(ability: [UIAbility](js-apis-app-ability-uiAbility.md)): void;
注册监听应用上下文的生命周期后,在ability销毁时触发回调。
......@@ -106,12 +106,12 @@ onAbilityDestroy(ability: UIAbility): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md#Ability) | 是 | 当前Ability对象 |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | 是 | 当前Ability对象 |
## AbilityLifecycleCallback.onAbilityForeground
onAbilityForeground(ability: UIAbility): void;
onAbilityForeground(ability: [UIAbility](js-apis-app-ability-uiAbility.md)): void;
注册监听应用上下文的生命周期后,在ability的状态从后台转到前台时触发回调。
......@@ -121,12 +121,12 @@ onAbilityForeground(ability: UIAbility): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md#Ability) | 是 | 当前Ability对象 |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | 是 | 当前Ability对象 |
## AbilityLifecycleCallback.onAbilityBackground
onAbilityBackground(ability: UIAbility): void;
onAbilityBackground(ability: [UIAbility](js-apis-app-ability-uiAbility.md)): void;
注册监听应用上下文的生命周期后,在ability的状态从前台转到后台时触发回调。
......@@ -136,12 +136,12 @@ onAbilityBackground(ability: UIAbility): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md#Ability) | 是 | 当前Ability对象 |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | 是 | 当前Ability对象 |
## AbilityLifecycleCallback.onAbilityContinue
onAbilityContinue(ability: UIAbility): void;
onAbilityContinue(ability: [UIAbility](js-apis-app-ability-uiAbility.md)): void;
注册监听应用上下文的生命周期后,在ability迁移时触发回调。
......@@ -151,61 +151,63 @@ onAbilityContinue(ability: UIAbility): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md#Ability) | 是 | 当前Ability对象 |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | 是 | 当前Ability对象 |
**示例:**
```ts
import AbilityLifecycleCallback from "@ohos.app.ability.AbilityLifecycleCallback";
```ts
import UIAbility from "@ohos.app.ability.UIAbility";
export default class MyAbility extends UIAbility {
onCreate() {
console.log("MyAbility onCreate")
let AbilityLifecycleCallback = {
onAbilityCreate(ability){
console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability));
},
onWindowStageCreate(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageCreate ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageCreate windowStage:" + JSON.stringify(windowStage));
},
onWindowStageActive(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageActive ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageActive windowStage:" + JSON.stringify(windowStage));
},
onWindowStageInactive(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageInactive ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageInactive windowStage:" + JSON.stringify(windowStage));
},
onWindowStageDestroy(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageDestroy ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageDestroy windowStage:" + JSON.stringify(windowStage));
},
onAbilityDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability));
},
onAbilityForeground(ability){
console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability));
},
onAbilityBackground(ability){
console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability));
},
onAbilityContinue(ability){
console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability));
}
}
// 1.通过context属性获取applicationContext
let applicationContext = this.context.getApplicationContext();
// 2.通过applicationContext注册监听应用内生命周期
let lifecycleid = applicationContext.on("abilityLifecycle", AbilityLifecycleCallback);
console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
},
onDestroy() {
let applicationContext = this.context.getApplicationContext();
applicationContext.off("abilityLifecycle", lifecycleid, (error, data) => {
console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
});
}
// 声明ability生命周期回调
let abilityLifecycleCallback = {
onAbilityCreate(ability){
console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability));
},
onWindowStageCreate(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageCreate ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageCreate windowStage:" + JSON.stringify(windowStage));
},
onWindowStageActive(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageActive ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageActive windowStage:" + JSON.stringify(windowStage));
},
onWindowStageInactive(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageInactive ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageInactive windowStage:" + JSON.stringify(windowStage));
},
onWindowStageDestroy(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageDestroy ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageDestroy windowStage:" + JSON.stringify(windowStage));
},
onAbilityDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability));
},
onAbilityForeground(ability){
console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability));
},
onAbilityBackground(ability){
console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability));
},
onAbilityContinue(ability){
console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability));
}
}
export default class MyAbility extends UIAbility {
onCreate() {
console.log("MyAbility onCreate")
// 1.通过context属性获取applicationContext
let applicationContext = this.context.getApplicationContext();
// 2.通过applicationContext注册监听应用内生命周期
globalThis.lifecycleid = applicationContext.on("abilityLifecycle", abilityLifecycleCallback);
console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
},
onDestroy() {
let applicationContext = this.context.getApplicationContext();
// 3.通过applicationContext注销监听应用内生命周期
applicationContext.off("abilityLifecycle", globalThis.lifecycleid, (error, data) => {
console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
});
}
```
\ No newline at end of file
}
```
\ No newline at end of file
......@@ -15,7 +15,7 @@ import abilityManager from '@ohos.app.ability.abilityManager'
## AbilityState
Ability的状态信息
Ability的状态,该类型为枚举,可配合[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)返回Abiltiy的状态
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
......@@ -23,15 +23,15 @@ Ability的状态信息。
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
| INITIAL | 0 | 表示ability为initial状态。|
| FOREGROUND | 9 | 表示ability为foreground状态。 |
| BACKGROUND | 10 | 表示ability为background状态。 |
| FOREGROUNDING | 11 | 表示ability为foregrounding状态。 |
| BACKGROUNDING | 12 | 表示ability为backgrounding状态。 |
| INITIAL | 0 | 表示ability为初始化状态。|
| FOREGROUND | 9 | 表示ability为前台状态。 |
| BACKGROUND | 10 | 表示ability为后台状态。 |
| FOREGROUNDING | 11 | 表示ability为前台调度中状态。 |
| BACKGROUNDING | 12 | 表示ability为后台调度中状态。 |
## updateConfiguration
updateConfiguration(config: Configuration, callback: AsyncCallback\<void>): void
updateConfiguration(config: [Configuration](js-apis-app-ability-configuration.md), callback: AsyncCallback\<void>): void
通过修改配置来更新配置(callback形式)。
......@@ -43,14 +43,19 @@ updateConfiguration(config: Configuration, callback: AsyncCallback\<void>): void
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ---------------------------------------- | ---- | -------------- |
| config | [Configuration](js-apis-app-ability-configuration.md) | 是 | 新的配置项。 |
| config | [Configuration](js-apis-app-ability-configuration.md) | 是 | 新的配置项,仅需配置需要更新的项。 |
| callback | AsyncCallback\<void> | 是 | 被指定的回调方法。 |
**示例**
```ts
var config = {
language: 'chinese'
language: 'chinese',
colorMode: COLOR_MODE_LIGHT,
direction: DIRECTION_VERTICAL,
screenDensity: SCREEN_DENSITY_SDPI,
displayId: 1,
hasPointerDevice: true,
}
try {
......@@ -65,7 +70,7 @@ try {
## updateConfiguration
updateConfiguration(config: Configuration): Promise\<void>
updateConfiguration(config: [Configuration](js-apis-app-ability-configuration.md)): Promise\<void>
通过修改配置来更新配置(Promise形式)。
......@@ -77,7 +82,7 @@ updateConfiguration(config: Configuration): Promise\<void>
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ---------------------------------------- | ---- | -------------- |
| config | [Configuration](js-apis-app-ability-configuration.md) | 是 | 新的配置项。 |
| config | [Configuration](js-apis-app-ability-configuration.md) | 是 | 新的配置项,仅需配置需要更新的项。 |
**返回值:**
......@@ -89,7 +94,12 @@ updateConfiguration(config: Configuration): Promise\<void>
```ts
var config = {
language: 'chinese'
language: 'chinese',
colorMode: COLOR_MODE_LIGHT,
direction: DIRECTION_VERTICAL,
screenDensity: SCREEN_DENSITY_SDPI,
displayId: 1,
hasPointerDevice: true,
}
try {
......@@ -106,7 +116,7 @@ try {
## getAbilityRunningInfos
getAbilityRunningInfos(callback: AsyncCallback\<Array\<AbilityRunningInfo>>): void
getAbilityRunningInfos(callback: AsyncCallback\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)>>): void
获取Ability运行相关信息(callback形式)。
......@@ -118,7 +128,7 @@ getAbilityRunningInfos(callback: AsyncCallback\<Array\<AbilityRunningInfo>>): vo
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback\<Array\<AbilityRunningInfo>> | 是 | 被指定的回调方法。 |
| callback | AsyncCallback\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)>> | 是 | 被指定的回调方法,返回运行中的ability信息。 |
**示例**
......@@ -135,7 +145,7 @@ try {
## getAbilityRunningInfos
getAbilityRunningInfos(): Promise\<Array\<AbilityRunningInfo>>
getAbilityRunningInfos(): Promise\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)>>
获取Ability运行相关信息(Promise形式)。
......@@ -147,7 +157,7 @@ getAbilityRunningInfos(): Promise\<Array\<AbilityRunningInfo>>
| 类型 | 说明 |
| ---------------------------------------- | ------- |
| Promise\<Array\<AbilityRunningInfo>> | 返回执行结果。 |
| Promise\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)>> | 返回运行中的ability信息。 |
**示例**
......@@ -166,7 +176,7 @@ try {
## getExtensionRunningInfos
getExtensionRunningInfos(upperLimit: number, callback: AsyncCallback\<Array\<ExtensionRunningInfo>>): void
getExtensionRunningInfos(upperLimit: number, callback: AsyncCallback\<Array\<[ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)>>): void
获取关于运行扩展能力的信息(callback形式)。
......@@ -179,7 +189,7 @@ getExtensionRunningInfos(upperLimit: number, callback: AsyncCallback\<Array\<Ext
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ---------------------------------------- | ---- | -------------- |
| upperLimit | number | 是 | 获取消息数量的最大限制。 |
| callback | AsyncCallback\<Array\<AbilityRunningInfo>> | 是 | 被指定的回调方法。 |
| callback | AsyncCallback\<Array\<[ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)>> | 是 | 被指定的回调方法,返回运行中的extension信息。 |
**示例**
......@@ -198,7 +208,7 @@ try {
## getExtensionRunningInfos
getExtensionRunningInfos(upperLimit: number): Promise\<Array\<ExtensionRunningInfo>>
getExtensionRunningInfos(upperLimit: number): Promise\<Array\<[ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)>>
获取关于运行扩展能力的信息(Promise形式)。
......@@ -216,7 +226,7 @@ getExtensionRunningInfos(upperLimit: number): Promise\<Array\<ExtensionRunningIn
| 类型 | 说明 |
| ---------------------------------------- | ------- |
| Promise\<Array\<AbilityRunningInfo>> | 返回执行结果。 |
| Promise\<Array\<[ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)>> | 返回运行中的extension信息。 |
**示例**
......@@ -225,9 +235,9 @@ var upperLimit = 0;
try {
abilityManager.getExtensionRunningInfos(upperLimit).then((data) => {
console.log("getAbilityRunningInfos data: " + JSON.stringify(data));
console.log("getExtensionRunningInfos data: " + JSON.stringify(data));
}).catch((err) => {
console.log("getAbilityRunningInfos err: " + err);
console.log("getExtensionRunningInfos err: " + err);
})
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code) +
......@@ -237,7 +247,7 @@ try {
## getTopAbility<sup>9+</sup>
getTopAbility(callback: AsyncCallback\<ElementName>): void;
getTopAbility(callback: AsyncCallback\<[ElementName](js-apis-bundleManager-elementName.md)>): void;
获取窗口焦点的ability接口(callback形式)。
......@@ -247,7 +257,7 @@ getTopAbility(callback: AsyncCallback\<ElementName>): void;
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback\<ElementName> | 是 | 被指定的回调方法。 |
| callback | AsyncCallback\<[ElementName](js-apis-bundleManager-elementName.md)> | 是 | 被指定的回调方法,返回目前获焦窗口的应用名。 |
**示例**
......@@ -259,7 +269,7 @@ abilityManager.getTopAbility((err,data) => {
## getTopAbility
getTopAbility(): Promise\<ElementName>;
getTopAbility(): Promise\<[ElementName](js-apis-bundleManager-elementName.md)>;
获取窗口焦点的ability接口(Promise形式)。
......@@ -269,7 +279,7 @@ getTopAbility(): Promise\<ElementName>;
| 类型 | 说明 |
| ---------------------------------------- | ------- |
| Promise\<ElementName>| 返回执行结果。 |
| Promise\<[ElementName](js-apis-bundleManager-elementName.md)>| 返回目前获焦窗口的应用名。 |
**示例**
......
......@@ -25,18 +25,18 @@ onCreate(): void
**示例:**
```ts
class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage.onCreate is called")
}
}
```
```ts
class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage.onCreate is called")
}
}
```
## AbilityStage.onAcceptWant
onAcceptWant(want: Want): string;
onAcceptWant(want: [Want](js-apis-app-ability-want.md)): string;
启动一个specified ability时触发的事件。
......@@ -56,19 +56,19 @@ onAcceptWant(want: Want): string;
**示例:**
```ts
class MyAbilityStage extends AbilityStage {
onAcceptWant(want) {
console.log("MyAbilityStage.onAcceptWant called");
return "com.example.test";
}
}
```
```ts
class MyAbilityStage extends AbilityStage {
onAcceptWant(want) {
console.log("MyAbilityStage.onAcceptWant called");
return "com.example.test";
}
}
```
## AbilityStage.onConfigurationUpdate
onConfigurationUpdate(newConfig: Configuration): void;
onConfigurationUpdate(newConfig: [Configuration](js-apis-app-ability-configuration.md)): void;
环境变化通知接口,发生全局配置变更时回调。
......@@ -82,17 +82,17 @@ onConfigurationUpdate(newConfig: Configuration): void;
**示例:**
```ts
class MyAbilityStage extends AbilityStage {
onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, language:' + config.language);
}
}
```
```ts
class MyAbilityStage extends AbilityStage {
onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, language:' + config.language);
}
}
```
## AbilityStage.onMemoryLevel
onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
onMemoryLevel(level: [AbilityConstant.MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel)): void;
当系统已决定调整内存时调用。例如,当该功能在后台运行时,没有足够的内存来运行尽可能多的后台进程时可以使用。
......@@ -106,17 +106,17 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
**示例:**
```ts
class MyAbilityStage extends AbilityStage {
```ts
class MyAbilityStage extends AbilityStage {
onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level));
}
}
```
}
```
## AbilityStage.context
context: AbilityStageContext;
context: [AbilityStageContext](js-apis-inner-application-abilityStageContext.md);
指示有关上下文的配置信息。
......
......@@ -14,7 +14,7 @@ import appRecovery from '@ohos.app.ability.appRecovery'
## appRecovery.RestartFlag
[enableAppRecovery](#apprecoveryenableapprecovery)接口重启选项参数
应用重启标志,[enableAppRecovery](#apprecoveryenableapprecovery)接口重启选项参数,该类型为枚举
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
......@@ -28,7 +28,7 @@ import appRecovery from '@ohos.app.ability.appRecovery'
## appRecovery.SaveOccasionFlag
[enableAppRecovery](#apprecoveryenableapprecovery)接口状态保存时机选项参数
保存条件标志,[enableAppRecovery](#apprecoveryenableapprecovery)接口状态保存时的选项参数,该类型为枚举
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
......@@ -39,7 +39,7 @@ import appRecovery from '@ohos.app.ability.appRecovery'
## appRecovery.SaveModeFlag
[enableAppRecovery](#apprecoveryenableapprecovery)接口状态保存方式的参数
状态保存标志,[enableAppRecovery](#apprecoveryenableapprecovery)接口状态保存方式的参数,该类型为枚举
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
......@@ -50,7 +50,7 @@ import appRecovery from '@ohos.app.ability.appRecovery'
## appRecovery.enableAppRecovery
enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void;
enableAppRecovery(restart?: [RestartFlag](#apprecoveryrestartflag), saveOccasion?: [SaveOccasionFlag](#apprecoverysaveoccasionflag), saveMode?: [SaveModeFlag](#apprecoverysavemodeflag)) : void;
使能应用恢复功能,参数按顺序填入。
......@@ -60,9 +60,9 @@ enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMo
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| restart | [RestartFlag](#apprecoveryrestartflag) | 否 | 发生对应故障时是否重启,默认为不重启。 |
| saveOccasion | [SaveOccasionFlag](#apprecoverysaveoccasionflag) | 否 | 状态保存时机,默认为故障时保存。 |
| saveMode | [SaveModeFlag](#apprecoverysavemodeflag) | 否 | 状态保存方式, 默认为文件缓存。 |
| restart | [RestartFlag](#apprecoveryrestartflag) | 否 | 枚举类型,发生对应故障时是否重启,默认为不重启。 |
| saveOccasion | [SaveOccasionFlag](#apprecoverysaveoccasionflag) | 否 | 枚举类型,状态保存时机,默认为故障时保存。 |
| saveMode | [SaveModeFlag](#apprecoverysavemodeflag) | 否 | 枚举类型,状态保存方式, 默认为文件缓存。 |
**示例:**
......@@ -94,7 +94,6 @@ var observer = {
appRecovery.restartApp();
}
}
```
## appRecovery.saveAppState
......@@ -109,7 +108,7 @@ saveAppState(): boolean;
| 类型 | 说明 |
| -------- | -------- |
| boolean | 保存成功与否。 |
| boolean | 保存成功与否。true:保存成功,false:保存失败。 |
**示例:**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册