未验证 提交 4db891df 编写于 作者: O openharmony_ci 提交者: Gitee

!18359 Fix release docs error of ability

Merge pull request !18359 from yuyaozhi/OpenHarmony-3.2-Release
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
当前卡片框架提供了如下几种按时间刷新卡片的方式: 当前卡片框架提供了如下几种按时间刷新卡片的方式:
- 定时刷新:表示在一定时间间隔内自动刷新卡片内容。可以在form_config.json配置文件的[`updateDuration`](arkts-ui-widget-configuration.md)字段中进行设置。例如,可以将刷新时间设置为每小时一次。 - 定时刷新:表示在一定时间间隔内调用[onUpdateForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onupdateform)的生命周期回调函数自动刷新卡片内容。可以在form_config.json配置文件的[`updateDuration`](arkts-ui-widget-configuration.md)字段中进行设置。例如,可以将刷新时间设置为每小时一次。
> **说明:** > **说明:**
> >
......
...@@ -30,7 +30,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant'; ...@@ -30,7 +30,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
Ability初次启动原因,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate)方法根据launchParam.launchReason的不同类型执行相应操作。 Ability初次启动原因,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate)方法根据launchParam.launchReason的不同类型执行相应操作。
**系统能力**以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ----------------------------- | ---- | ------------------------------------------------------------ | | ----------------------------- | ---- | ------------------------------------------------------------ |
...@@ -58,7 +58,7 @@ class MyAbility extends UIAbility { ...@@ -58,7 +58,7 @@ class MyAbility extends UIAbility {
Ability上次退出原因,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate)方法根据launchParam.lastExitReason的不同类型执行相应操作。 Ability上次退出原因,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate)方法根据launchParam.lastExitReason的不同类型执行相应操作。
**系统能力**以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ----------------------------- | ---- | ------------------------------------------------------------ | | ----------------------------- | ---- | ------------------------------------------------------------ |
...@@ -84,7 +84,7 @@ class MyAbility extends UIAbility { ...@@ -84,7 +84,7 @@ class MyAbility extends UIAbility {
Ability迁移结果,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onContinue(wantParam)](js-apis-app-ability-uiAbility.md#uiabilityoncontinue)方法进完成相应的返回。 Ability迁移结果,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onContinue(wantParam)](js-apis-app-ability-uiAbility.md#uiabilityoncontinue)方法进完成相应的返回。
**系统能力**以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ----------------------------- | ---- | ------------------------------------------------------------ | | ----------------------------- | ---- | ------------------------------------------------------------ |
......
...@@ -44,8 +44,6 @@ getAbilityDelegator(): AbilityDelegator ...@@ -44,8 +44,6 @@ getAbilityDelegator(): AbilityDelegator
**示例:** **示例:**
```ts ```ts
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let want = { let want = {
...@@ -78,8 +76,6 @@ getArguments(): AbilityDelegatorArgs ...@@ -78,8 +76,6 @@ getArguments(): AbilityDelegatorArgs
**示例:** **示例:**
```ts ```ts
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
let args = AbilityDelegatorRegistry.getArguments(); let args = AbilityDelegatorRegistry.getArguments();
console.info('getArguments bundleName:' + args.bundleName); console.info('getArguments bundleName:' + args.bundleName);
console.info('getArguments parameters:' + JSON.stringify(args.parameters)); console.info('getArguments parameters:' + JSON.stringify(args.parameters));
......
...@@ -669,7 +669,11 @@ killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\> ...@@ -669,7 +669,11 @@ killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\>
切断account进程(Promise形式)。 切断account进程(Promise形式)。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。 > **说明:**
>
> 当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
...@@ -715,12 +719,16 @@ killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCal ...@@ -715,12 +719,16 @@ killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCal
切断account进程(callback形式)。 切断account进程(callback形式)。
> **说明:**
>
> 当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**: 此接口为系统接口,三方应用不支持调用。 **系统API**: 此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
......
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
> >
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```ts
import Configuration from '@ohos.app.ability.Configuration';
```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
......
# @ohos.app.ability.dataUriUtils (DataUriUtils模块) # @ohos.app.ability.dataUriUtils (DataUriUtils模块)
DataUriUtils模块提供用于处理uri对象的能力,包括获取、绑定、删除和更新指定uri对象的路径末尾的ID。 DataUriUtils模块提供用于处理uri对象的能力,包括获取、绑定、删除和更新指定uri对象的路径末尾的ID。
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
import dataUriUtils from '@ohos.app.ability.dataUriUtils'; import dataUriUtils from '@ohos.app.ability.dataUriUtils';
``` ```
## dataUriUtils.getId ## dataUriUtils.getId
getId(uri: string): number getId(uri: string): number
获取指定uri路径末尾的ID。 获取指定uri路径末尾的ID。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | --------------------------- | | ---- | ------ | ---- | --------------------------- |
| uri | string | 是 | 表示uri对象。 | | uri | string | 是 | 表示uri对象。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ------------------------ | | ------ | ------------------------ |
| number | 返回uri路径末尾的ID。 | | number | 返回uri路径末尾的ID。 |
**示例:** **示例:**
```ts ```ts
try { try {
let id = dataUriUtils.getId('com.example.dataUriUtils/1221'); let id = dataUriUtils.getId('com.example.dataUriUtils/1221');
console.info('get id: ${id}'); console.info('get id: ${id}');
} catch(err) { } catch(err) {
console.error('get id err ,check the uri ${err}'); console.error('get id err ,check the uri ${err}');
} }
``` ```
## dataUriUtils.attachId
attachId(uri: string, id: number): string ## dataUriUtils.attachId
将ID附加到uri的路径末尾。 attachId(uri: string, id: number): string
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 将ID附加到uri的路径末尾。
**参数:** **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 类型 | 必填 | 描述 | **参数:**
| ---- | ------ | ---- | --------------------------- |
| uri | string | 是 | 表示uri对象。 | | 参数名 | 类型 | 必填 | 说明 |
| id | number | 是 | 表示要附加的ID。 | | ---- | ------ | ---- | --------------------------- |
| uri | string | 是 | 表示uri对象。 |
**返回值:** | id | number | 是 | 表示要附加的ID。 |
| 类型 | 说明 | **返回值:**
| ------ | --------------------- |
| string | 返回附加ID之后的uri对象。 | | 类型 | 说明 |
| ------ | --------------------- |
**示例:** | string | 返回附加ID之后的uri对象。 |
```ts **示例:**
let id = 1122;
try { ```ts
let uri = dataUriUtils.attachId( let id = 1122;
'com.example.dataUriUtils', try {
id, let uri = dataUriUtils.attachId(
); 'com.example.dataUriUtils',
console.info('attachId the uri is: ${uri}'); id,
} catch (err) { );
console.error('get id err ,check the uri ${err}'); console.info('attachId the uri is: ${uri}');
} } catch (err) {
console.error('get id err ,check the uri ${err}');
``` }
## dataUriUtils.deleteId ```
deleteId(uri: string): string
删除指定uri路径末尾的ID。 ## dataUriUtils.deleteId
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core deleteId(uri: string): string
**参数:** 删除指定uri路径末尾的ID。
| 名称 | 类型 | 必填 | 描述 | **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| ---- | ------ | ---- | --------------------------- |
| uri | string | 是 | 表示要从中删除ID的uri对象。 | **参数:**
**返回值:** | 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | --------------------------- |
| 类型 | 说明 | | uri | string | 是 | 表示要从中删除ID的uri对象。 |
| ------ | ------------------- |
| string | 返回删除ID之后的uri对象。 | **返回值:**
**示例:** | 类型 | 说明 |
| ------ | ------------------- |
```ts | string | 返回删除ID之后的uri对象。 |
try {
let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221'); **示例:**
console.info('delete id with the uri is: ${uri}');
} catch(err) { ```ts
console.error('delete uri err, check the input uri ${err}'); try {
} let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221');
console.info('delete id with the uri is: ${uri}');
``` } catch(err) {
console.error('delete uri err, check the input uri ${err}');
## dataUriUtils.updateId }
updateId(uri: string, id: number): string ```
更新指定uri中的ID。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core ## dataUriUtils.updateId
**参数:** updateId(uri: string, id: number): string
| 名称 | 类型 | 必填 | 描述 | 更新指定uri中的ID。
| ---- | ------ | ---- | ------------------- |
| uri | string | 是 | 表示uri对象 | **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| id | number | 是 | 表示要更新的ID |
**参数:**
**返回值:**
| 参数名 | 类型 | 必填 | 说明 |
| 类型 | 说明 | | ---- | ------ | ---- | ------------------- |
| ------ | --------------- | | uri | string | 是 | 表示uri对象 |
| string | 返回更新ID之后的uri对象。 | | id | number | 是 | 表示要更新的ID |
**示例:** **返回值:**
```ts | 类型 | 说明 |
| ------ | --------------- |
try { | string | 返回更新ID之后的uri对象。 |
let id = 1122;
let uri = dataUriUtils.updateId( **示例:**
'com.example.dataUriUtils/1221',
id ```ts
);
} catch (err) { try {
console.error('delete uri err, check the input uri ${err}'); let id = 1122;
} let uri = dataUriUtils.updateId(
``` 'com.example.dataUriUtils/1221',
id
);
} catch (err) {
console.error('delete uri err, check the input uri ${err}');
}
```
# @ohos.app.ability.dialogRequest (dialogRequest模块) # @ohos.app.ability.dialogRequest (dialogRequest模块)
dialogRequest模块用于处理模态弹框的能力,包括获取RequestInfo(用于绑定模态弹框)、获取RequestCallback(用于设置结果)。 dialogRequest模块用于处理模态弹框的能力,包括获取RequestInfo(用于绑定模态弹框)、获取RequestCallback(用于设置结果)。
模态弹框是指一个系统弹出框,其特点在于:该弹出框会拦截弹框之下的页面的鼠标、键盘、触屏等事件,销毁该弹框,才能操作下面的页面。 模态弹框是指一个系统弹出框,其特点在于:该弹出框会拦截弹框之下的页面的鼠标、键盘、触屏等事件,销毁该弹框,才能操作下面的页面。
> **说明:** > **说明:**
> >
> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口在ServiceExtensionAbility下使用,如果ServiceExtensionAbility实现了模态弹框,则可以使用本模块的接口获取请求方的RequestInfo、RequestCallback并返回请求结果。 > - 本模块接口在ServiceExtensionAbility下使用,如果ServiceExtensionAbility实现了模态弹框,则可以使用本模块的接口获取请求方的RequestInfo、RequestCallback并返回请求结果。
## 导入模块 ## 导入模块
```js ```js
import dialogRequest from '@ohos.app.ability.dialogRequest'; import dialogRequest from '@ohos.app.ability.dialogRequest';
``` ```
## dialogRequest.getRequestInfo ## dialogRequest.getRequestInfo
getRequestInfo(want: Want): RequestInfo getRequestInfo(want: Want): RequestInfo
从Want中获取请求方的RequestInfo。 从Want中获取请求方的RequestInfo。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | --------------------------- | | ---- | ------ | ---- | --------------------------- |
| want | [Want](js-apis-application-want.md) | 是 | 表示发起方请求弹框时传入的want信息。 | | want | [Want](js-apis-application-want.md) | 是 | 表示发起方请求弹框时传入的want信息。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ------------------------ | | ------ | ------------------------ |
| [RequestInfo](#requestinfo) | 请求方RequestInfo,用于绑定模态窗口。 | | [RequestInfo](#requestinfo) | 请求方RequestInfo,用于绑定模态窗口。 |
**示例:** **示例:**
```ts ```ts
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'; import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
import dialogRequest from '@ohos.app.ability.dialogRequest'; import dialogRequest from '@ohos.app.ability.dialogRequest';
export default class ServiceExtAbility extends ServiceExtensionAbility { const REQUEST_VALUE = 1;
onCreate(want) {
console.info(TAG, `onCreate, want: ${want.abilityName}`); class StubTest extends rpc.RemoteObject {
} constructor(des) {
super(des);
onRequest(want, startId) { }
console.info(TAG, `onRequest, want: ${want.abilityName}`);
try { onRemoteRequest(code, data, reply, option) {
var requestInfo = dialogRequest.getRequestInfo(want); if (code === REQUEST_VALUE) {
} catch(err) { let optFir = data.readInt();
console.error('getRequestInfo err= ${JSON.stringify(err)}'); let optSec = data.readInt();
} reply.writeInt(optFir + optSec);
} }
return true;
onConnect(want) { }
console.info(TAG, `onConnect, want: ${want.abilityName}`);
} queryLocallInterface(descriptor) {
return null;
onDisconnect(want) { }
console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
} getInterfaceDescriptor() {
return "";
onDestroy() { }
console.info(TAG, `onDestroy`);
} getCallingPid() {
} return REQUEST_VALUE;
``` }
## dialogRequest.getRequestCallback getCallingUid() {
return REQUEST_VALUE;
getRequestCallback(want: Want): RequestCallback }
从Want中获取请求方的RequestCallback。 attachLocalInterface(localInterface, descriptor) {
}
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core }
**参数:** let TAG = "getRequestInfoTest";
| 名称 | 类型 | 必填 | 描述 | export default class ServiceExtAbility extends ServiceExtensionAbility {
| ---- | ------ | ---- | --------------------------- | onCreate(want) {
| want | [Want](js-apis-application-want.md) | 是 | 表示发起方请求弹框时传入的want信息。 | console.info(TAG, `onCreate, want: ${want.abilityName}`);
}
**返回值:**
onRequest(want, startId) {
| 类型 | 说明 | console.info(TAG, `onRequest, want: ${want.abilityName}`);
| ------ | ------------------------ | try {
| [RequestCallback](#requestcallback) | 请求方RequestCallback,用于设置返回结果。 | var requestInfo = dialogRequest.getRequestInfo(want);
} catch (err) {
**示例:** console.error('getRequestInfo err= ${JSON.stringify(err)}');
}
```ts }
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
import rpc from '@ohos.rpc'; onConnect(want) {
import dialogRequest from '@ohos.app.ability.dialogRequest'; console.info(TAG, `onConnect, want: ${want.abilityName}`);
return new StubTest("test");
export default class ServiceExtAbility extends ServiceExtensionAbility { }
onCreate(want) {
console.info(TAG, `onCreate, want: ${want.abilityName}`); onDisconnect(want) {
} console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
}
onRequest(want, startId) {
console.info(TAG, `onRequest, want: ${want.abilityName}`); onDestroy() {
try { console.info(TAG, `onDestroy`);
var requestCallback = dialogRequest.getRequestCallback(want); }
} catch(err) { }
console.error('getRequestInfo err= ${JSON.stringify(err)}'); ```
}
} ## dialogRequest.getRequestCallback
onConnect(want) { getRequestCallback(want: Want): RequestCallback
console.info(TAG, `onConnect, want: ${want.abilityName}`);
} 从Want中获取请求方的RequestCallback。
onDisconnect(want) { **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
} **参数:**
onDestroy() { | 参数名 | 类型 | 必填 | 说明 |
console.info(TAG, `onDestroy`); | ---- | ------ | ---- | --------------------------- |
} | want | [Want](js-apis-application-want.md) | 是 | 表示发起方请求弹框时传入的want信息。 |
}
``` **返回值:**
## RequestInfo | 类型 | 说明 |
| ------ | ------------------------ |
表示发起方请求信息,作为窗口绑定模态弹框的入参。 | [RequestCallback](#requestcallback) | 请求方RequestCallback,用于设置返回结果。 |
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore
**示例:**
**示例:**
```ts
```ts import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'; import rpc from '@ohos.rpc';
import rpc from '@ohos.rpc'; import dialogRequest from '@ohos.app.ability.dialogRequest';
import dialogRequest from '@ohos.app.ability.dialogRequest';
import window from '@ohos.window'; let TAG = "getRequestCallbackTest";
export default class ServiceExtAbility extends ServiceExtensionAbility { const REQUEST_VALUE = 1;
onCreate(want) {
console.info(TAG, `onCreate, want: ${want.abilityName}`); class StubTest extends rpc.RemoteObject {
} constructor(des) {
super(des);
onRequest(want, startId) { }
console.info(TAG, `onRequest, want: ${want.abilityName}`);
try { onRemoteRequest(code, data, reply, option) {
var requestInfo = dialogRequest.getRequestInfo(want); if (code === REQUEST_VALUE) {
window.bindDialogTarget(requestInfo, () => { let optFir = data.readInt();
console.info('Dialog Window Need Destroy.'); let optSec = data.readInt();
}, (err) => { reply.writeInt(optFir + optSec);
if (err.code) { }
console.error('Failed to bind dialog target. Cause: ${JSON.stringify(err)}'); return true;
return; }
}
console.info('Succeeded in binding dialog target.'); queryLocallInterface(descriptor) {
}); return null;
} catch(err) { }
console.error('getRequestInfo err= ${JSON.stringify(err)}');
} getInterfaceDescriptor() {
} return "";
}
onConnect(want) {
console.info(TAG, `onConnect, want: ${want.abilityName}`); getCallingPid() {
} return REQUEST_VALUE;
}
onDisconnect(want) {
console.info(TAG, `onDisconnect, want: ${want.abilityName}`); getCallingUid() {
} return REQUEST_VALUE;
}
onDestroy() {
console.info(TAG, `onDestroy`); attachLocalInterface(localInterface, descriptor) {
} }
} }
```
export default class ServiceExtAbility extends ServiceExtensionAbility {
## ResultCode onCreate(want) {
console.info(TAG, `onCreate, want: ${want.abilityName}`);
模态弹框请求结果码。 }
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore。 onRequest(want, startId) {
console.info(TAG, `onRequest, want: ${want.abilityName}`);
| 名称 | 值 | 说明 | try {
| ------------ | ------------------ | ---------------------- | var requestCallback = dialogRequest.getRequestCallback(want);
| RESULT_OK | 0 | 表示成功。 | } catch(err) {
| RESULT_CANCEL | 1 | 表示失败。 | console.error('getRequestInfo err= ${JSON.stringify(err)}');
}
## RequestResult }
模态弹框请求结果,当前只包含结果码,即RequestResult只当前只有ResultCode这一个成员。
onConnect(want) {
## 属性 console.info(TAG, `onConnect, want: ${want.abilityName}`);
return new StubTest("test");
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore }
| 名称 | 类型 | 可读 | 可写 | 说明 | onDisconnect(want) {
| -------- | -------- | -------- | -------- | -------- | console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
| result | [ResultCode](#resultcode) | 是 | 是 | 表示结果码。 | }
## RequestCallback onDestroy() {
console.info(TAG, `onDestroy`);
用于设置模态弹框请求结果的callback接口。 }
}
### RequestCallback.setRequestResult ```
setRequestResult(result: RequestResult): void; ## RequestInfo
设置请求结果 表示发起方请求信息,作为窗口绑定模态弹框的入参。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore
**示例:**
**参数:**
```ts
| 参数名 | 类型 | 必填 | 说明 | import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
| -------- | -------- | -------- | -------- | import rpc from '@ohos.rpc';
| result | [RequestResult](#requestresult) | 是 | 模态弹框请求结果信息。 | import dialogRequest from '@ohos.app.ability.dialogRequest';
import window from '@ohos.window';
**错误码:**
let TAG = "RequestInfoTest";
| 错误码ID | 错误信息 |
| ------- | -------------------------------- | const REQUEST_VALUE = 1;
| 401 | If the input parameter is not valid parameter. |
class StubTest extends rpc.RemoteObject {
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) constructor(des) {
super(des);
**示例:** }
```ts onRemoteRequest(code, data, reply, option) {
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'; if (code === REQUEST_VALUE) {
import rpc from '@ohos.rpc'; let optFir = data.readInt();
import dialogRequest from '@ohos.app.ability.dialogRequest'; let optSec = data.readInt();
reply.writeInt(optFir + optSec);
export default class ServiceExtAbility extends ServiceExtensionAbility { }
onCreate(want) { return true;
console.info(TAG, `onCreate, want: ${want.abilityName}`); }
}
queryLocallInterface(descriptor) {
onRequest(want, startId) { return null;
console.info(TAG, `onRequest, want: ${want.abilityName}`); }
try {
var requestCallback = dialogRequest.getRequestCallback(want); getInterfaceDescriptor() {
let myResult = { return "";
result : dialogRequest.ResultCode.RESULT_CANCEL, }
};
requestCallback.setRequestResult(myResult); getCallingPid() {
} catch(err) { return REQUEST_VALUE;
console.error('getRequestInfo err= ${JSON.stringify(err)}'); }
}
} getCallingUid() {
return REQUEST_VALUE;
onConnect(want) { }
console.info(TAG, `onConnect, want: ${want.abilityName}`);
} attachLocalInterface(localInterface, descriptor) {
}
onDisconnect(want) { }
console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
} export default class ServiceExtAbility extends ServiceExtensionAbility {
onCreate(want) {
onDestroy() { console.info(TAG, `onCreate, want: ${want.abilityName}`);
console.info(TAG, `onDestroy`); }
}
} onRequest(want, startId) {
console.info(TAG, `onRequest, want: ${want.abilityName}`);
try {
var requestInfo = dialogRequest.getRequestInfo(want);
window.bindDialogTarget(requestInfo, () => {
console.info('Dialog Window Need Destroy.');
}, (err) => {
if (err.code) {
console.error('Failed to bind dialog target. Cause: ${JSON.stringify(err)}');
return;
}
console.info('Succeeded in binding dialog target.');
});
} catch(err) {
console.error('getRequestInfo err= ${JSON.stringify(err)}');
}
}
onConnect(want) {
console.info(TAG, `onConnect, want: ${want.abilityName}`);
return new StubTest("test");
}
onDisconnect(want) {
console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
}
onDestroy() {
console.info(TAG, `onDestroy`);
}
}
```
## ResultCode
模态弹框请求结果码。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| 参数名 | 值 | 说明 |
| ------------ | ------------------ | ---------------------- |
| RESULT_OK | 0 | 表示成功。 |
| RESULT_CANCEL | 1 | 表示失败。 |
## RequestResult
模态弹框请求结果,当前只包含结果码,即RequestResult只当前只有ResultCode这一个成员。
## 属性
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| result | [ResultCode](#resultcode) | 是 | 是 | 表示结果码。 |
## RequestCallback
用于设置模态弹框请求结果的callback接口。
### RequestCallback.setRequestResult
setRequestResult(result: RequestResult): void;
设置请求结果
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| result | [RequestResult](#requestresult) | 是 | 模态弹框请求结果信息。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
**示例:**
```ts
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
import rpc from '@ohos.rpc';
import dialogRequest from '@ohos.app.ability.dialogRequest';
let TAG = "setRequestResultTest";
const REQUEST_VALUE = 1;
class StubTest extends rpc.RemoteObject {
constructor(des) {
super(des);
}
onRemoteRequest(code, data, reply, option) {
if (code === REQUEST_VALUE) {
let optFir = data.readInt();
let optSec = data.readInt();
reply.writeInt(optFir + optSec);
}
return true;
}
queryLocallInterface(descriptor) {
return null;
}
getInterfaceDescriptor() {
return "";
}
getCallingPid() {
return REQUEST_VALUE;
}
getCallingUid() {
return REQUEST_VALUE;
}
attachLocalInterface(localInterface, descriptor) {
}
}
export default class ServiceExtAbility extends ServiceExtensionAbility {
onCreate(want) {
console.info(TAG, `onCreate, want: ${want.abilityName}`);
}
onRequest(want, startId) {
console.info(TAG, `onRequest, want: ${want.abilityName}`);
try {
var requestCallback = dialogRequest.getRequestCallback(want);
let myResult = {
result : dialogRequest.ResultCode.RESULT_CANCEL,
};
requestCallback.setRequestResult(myResult);
} catch(err) {
console.error('getRequestInfo err= ${JSON.stringify(err)}');
}
}
onConnect(want) {
console.info(TAG, `onConnect, want: ${want.abilityName}`);
return new StubTest("test");
}
onDisconnect(want) {
console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
}
onDestroy() {
console.info(TAG, `onDestroy`);
}
}
``` ```
\ No newline at end of file
...@@ -45,9 +45,8 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void; ...@@ -45,9 +45,8 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
**示例:** **示例:**
```ts
```ts import UIAbility from '@ohos.app.ability.Ability';
import UIAbility from '@ohos.app.ability.UIAbility';
let callbackId; let callbackId;
...@@ -57,8 +56,9 @@ export default class MyAbility extends UIAbility { ...@@ -57,8 +56,9 @@ export default class MyAbility extends UIAbility {
globalThis.applicationContext = this.context.getApplicationContext(); globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = { let EnvironmentCallback = {
onConfigurationUpdated(config){ onConfigurationUpdated(config){
console.log('onConfigurationUpdated config:' + JSON.stringify(config)); console.log(`onConfigurationUpdated config: ${JSON.stringify(config)}`);
}, },
onMemoryLevel(level){ onMemoryLevel(level){
console.log('onMemoryLevel level: ${JSON.stringify(level)}'); console.log('onMemoryLevel level: ${JSON.stringify(level)}');
} }
...@@ -76,4 +76,4 @@ export default class MyAbility extends UIAbility { ...@@ -76,4 +76,4 @@ export default class MyAbility extends UIAbility {
}); });
} }
} }
``` ```
\ No newline at end of file \ No newline at end of file
...@@ -66,10 +66,10 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<v ...@@ -66,10 +66,10 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<v
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------- | | ------- | -------- |
| 18500002 | Copy file failed, maybe not exist or inaccessible. | | 18500002 | The specified quick fix is invalid. It may not exist or inaccessible. |
| 18500008 | Internal error. | | 18500008 | Internal error. |
在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9)的参数返回给应用开发者。这部分错误码及错误信息如下: 在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEventManager-definitions.md#common_event_quick_fix_apply_result-9)的参数返回给应用开发者。这部分错误码及错误信息如下:
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------- | | ------- | -------- |
...@@ -130,10 +130,10 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>; ...@@ -130,10 +130,10 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------- | | ------- | -------- |
| 18500002 | Copy file failed, maybe not exist or inaccessible. | | 18500002 | The specified quick fix is invalid. It may not exist or inaccessible. |
| 18500008 | Internal error. | | 18500008 | Internal error. |
在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9)的参数返回给应用开发者。这部分错误码及错误信息如下: 在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEventManager-definitions.md#common_event_quick_fix_apply_result-9)的参数返回给应用开发者。这部分错误码及错误信息如下:
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------- | | ------- | -------- |
...@@ -185,7 +185,7 @@ getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\<Applicat ...@@ -185,7 +185,7 @@ getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\<Applicat
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------- | | ------- | -------- |
| 18500001 | The bundle is not exist. | | 18500001 | The specified bundleName is invalid. |
| 18500008 | Internal error. | | 18500008 | Internal error. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
...@@ -237,7 +237,7 @@ getApplicationQuickFixInfo(bundleName: string): Promise\<ApplicationQuickFixInfo ...@@ -237,7 +237,7 @@ getApplicationQuickFixInfo(bundleName: string): Promise\<ApplicationQuickFixInfo
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------- | | ------- | -------- |
| 18500001 | The bundle is not exist. | | 18500001 | The specified bundleName is invalid. |
| 18500008 | Internal error. | | 18500008 | Internal error. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
......
...@@ -15,11 +15,8 @@ import StartOptions from '@ohos.app.ability.StartOptions'; ...@@ -15,11 +15,8 @@ import StartOptions from '@ohos.app.ability.StartOptions';
## 属性 ## 属性
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| [windowMode](js-apis-app-ability-abilityConstant.md#abilityconstantwindowmode) | number | 否 | 窗口模式。 | | [windowMode](js-apis-app-ability-abilityConstant.md#abilityconstantwindowmode) | number | 否 | 窗口模式。 |
......
...@@ -333,7 +333,7 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;; ...@@ -333,7 +333,7 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;;
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 16200001 | Caller released. The caller has been released. | | 16200001 | Caller released. The caller has been released. |
| 16200002 | Callee invalid. The callee does not exist. | | 16200002 | Callee invalid. The callee does not exist. |
| 16000050 | Internal Error. | | 16000050 | Internal error. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
...@@ -416,7 +416,7 @@ callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageSequ ...@@ -416,7 +416,7 @@ callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageSequ
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 16200001 | Caller released. The caller has been released. | | 16200001 | Caller released. The caller has been released. |
| 16200002 | Callee invalid. The callee does not exist. | | 16200002 | Callee invalid. The callee does not exist. |
| 16000050 | Internal Error. | | 16000050 | Internal error. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
...@@ -569,7 +569,7 @@ release(): void; ...@@ -569,7 +569,7 @@ release(): void;
## Caller.on ## Caller.on
on(type: 'release', callback: OnReleaseCallback): void; on(type: 'release', callback: OnReleaseCallback): void;
注册通用组件服务端Stub(桩)断开监听通知。 注册通用组件服务端Stub(桩)断开监听通知。
...@@ -586,6 +586,7 @@ release(): void; ...@@ -586,6 +586,7 @@ release(): void;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
| 16200001 | Caller released. The caller has been released. | | 16200001 | Caller released. The caller has been released. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
......
...@@ -26,7 +26,7 @@ import Want from '@ohos.app.ability.Want'; ...@@ -26,7 +26,7 @@ import Want from '@ohos.app.ability.Want';
| entities | Array\<string> | 否 | 表示目标Ability额外的类别信息(如:浏览器、视频播放器)。在隐式Want中是对action字段的补充。在隐式Want中,您可以定义该字段,来过滤匹配Ability类型。 | | entities | Array\<string> | 否 | 表示目标Ability额外的类别信息(如:浏览器、视频播放器)。在隐式Want中是对action字段的补充。在隐式Want中,您可以定义该字段,来过滤匹配Ability类型。 |
| uri | string | 否 | 表示携带的数据,一般配合type使用,指明待处理的数据类型。如果在Want中指定了uri,则Want将匹配指定的Uri信息,包括`scheme``schemeSpecificPart``authority``path`信息。 | | uri | string | 否 | 表示携带的数据,一般配合type使用,指明待处理的数据类型。如果在Want中指定了uri,则Want将匹配指定的Uri信息,包括`scheme``schemeSpecificPart``authority``path`信息。 |
| type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:'text/xml' 、 'image/*'等,MIME定义请参见https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 | | type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:'text/xml' 、 'image/*'等,MIME定义请参见https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 |
| parameters | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:<br />- ohos.aafwk.callerPid:表示拉起方的pid。<br />- ohos.aafwk.param.callerBundleName:表示拉起方的Bundle Name。<br />- ohos.aafwk.param.callerToken:表示拉起方的token。<br />- ohos.aafwk.param.callerUid:表示[BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。<br />- component.startup.newRules:表示是否启用新的管控规则。<br />- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。<br />- ohos.dlp.params.sandbox:表示dlp文件才会有。 | | parameters | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:<br />- ohos.aafwk.callerPid:表示拉起方的pid。<br />- ohos.aafwk.param.callerBundleName:表示拉起方的Bundle Name。<br />- ohos.aafwk.param.callerToken:表示拉起方的token。<br />- ohos.aafwk.param.callerUid:表示[BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。<br />- component.startup.newRules:表示是否启用新的管控规则。<br />- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。<br />- ohos.dlp.params.sandbox:表示dlp文件才会有。<br />- ability.params.backToOtherMissionStack:表示是否支持跨任务链返回。 |
| [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | 否 | 表示处理Want的方式。默认传数字。<br />例如通过wantConstant.Flags.FLAG_ABILITY_CONTINUATION表示是否以设备间迁移方式启动Ability。 | | [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | 否 | 表示处理Want的方式。默认传数字。<br />例如通过wantConstant.Flags.FLAG_ABILITY_CONTINUATION表示是否以设备间迁移方式启动Ability。 |
**示例:** **示例:**
...@@ -34,7 +34,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -34,7 +34,8 @@ import Want from '@ohos.app.ability.Want';
- 基础用法:在UIAbility对象中调用,示例中的context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息) - 基础用法:在UIAbility对象中调用,示例中的context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)
```ts ```ts
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = { let want = {
'deviceId': '', // deviceId为空表示本设备 'deviceId': '', // deviceId为空表示本设备
'bundleName': 'com.example.myapplication', 'bundleName': 'com.example.myapplication',
...@@ -52,7 +53,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -52,7 +53,8 @@ import Want from '@ohos.app.ability.Want';
* 字符串(String) * 字符串(String)
```ts ```ts
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = { let want = {
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility', abilityName: 'FuncAbility',
...@@ -67,7 +69,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -67,7 +69,8 @@ import Want from '@ohos.app.ability.Want';
``` ```
* 数字(Number) * 数字(Number)
```ts ```ts
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = { let want = {
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility', abilityName: 'FuncAbility',
...@@ -83,7 +86,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -83,7 +86,8 @@ import Want from '@ohos.app.ability.Want';
``` ```
* 布尔(Boolean) * 布尔(Boolean)
```ts ```ts
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = { let want = {
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility', abilityName: 'FuncAbility',
...@@ -98,7 +102,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -98,7 +102,8 @@ import Want from '@ohos.app.ability.Want';
``` ```
* 对象(Object) * 对象(Object)
```ts ```ts
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = { let want = {
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility', abilityName: 'FuncAbility',
...@@ -118,7 +123,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -118,7 +123,8 @@ import Want from '@ohos.app.ability.Want';
``` ```
* 数组(Array) * 数组(Array)
```ts ```ts
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = { let want = {
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility', abilityName: 'FuncAbility',
...@@ -138,7 +144,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -138,7 +144,8 @@ import Want from '@ohos.app.ability.Want';
```ts ```ts
import fs from '@ohos.file.fs'; import fs from '@ohos.file.fs';
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let fd; let fd;
try { try {
...@@ -160,3 +167,33 @@ import Want from '@ohos.app.ability.Want'; ...@@ -160,3 +167,33 @@ import Want from '@ohos.app.ability.Want';
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`); console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
- parameter参数用法:以ability.params.backToOtherMissionStack为例,ServiceExtension在拉起UIAbility的时候,可以支持跨任务链返回。
```ts
// (1) UIAbility1启动一个ServiceExtension
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = {
bundleName: 'com.example.myapplication1',
abilityName: 'ServiceExtensionAbility',
};
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
// (2) 该ServiceExtension去启动另一个UIAbility2,并在启动的时候携带参数ability.params.backToOtherMissionStack为true
let context = ...; // ServiceExtensionContext
let want = {
bundleName: 'com.example.myapplication2',
abilityName: 'MainAbility',
parameters: {
"ability.params.backToOtherMissionStack": true,
},
};
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
说明:上例中,如果ServiceExtension启动UIAbility2时不携带ability.params.backToOtherMissionStack参数,或者携带的ability.params.backToOtherMissionStack参数为false,则UIAbility1和UIAbility2不在同一个任务栈里面,在UIAbility2的界面点back键,不会回到UIAbility1的界面。如果携带的ability.params.backToOtherMissionStack参数为true,则表示支持跨任务链返回,此时在UIAbility2的界面点back键,会回到UIAbility1的界面。
...@@ -113,10 +113,8 @@ getWantAgent(info: WantAgentInfo): Promise\<WantAgent\> ...@@ -113,10 +113,8 @@ getWantAgent(info: WantAgentInfo): Promise\<WantAgent\>
**示例:** **示例:**
```js ```ts
import WantAgent from '@ohos.app.ability.wantAgent'; let wantAgent;
//WantAgentInfo对象 //WantAgentInfo对象
let wantAgentInfo = { let wantAgentInfo = {
wants: [ wants: [
...@@ -1126,6 +1124,27 @@ let wantAgentInfo = { ...@@ -1126,6 +1124,27 @@ let wantAgentInfo = {
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}; };
//getWantAgent回调
function getWantAgentCallback(err, data) {
if (err === undefined) {
wantAgent = data;
} else {
console.error('getWantAgent failed ${JSON.stringify(wantAgent)}');
}
//getOperationTypeCallback回调
function getOperationTypeCallback(err, data) {
if(err) {
console.error('getOperationType failed! ${err.code} ${err.message}');
} else {
console.info('getOperationType ok! ${JSON.stringify(data)}');
}
}
try {
WantAgent.getOperationType(wantAgent, getOperationTypeCallback);
} catch(err) {
console.error('getOperationTypeCallback failed! ${err.code} ${err.message}');
}
}
try { try {
WantAgent.getWantAgent(wantAgentInfo).then((data) => { WantAgent.getWantAgent(wantAgentInfo).then((data) => {
console.info('==========================>getWantAgentCallback=======================>'); console.info('==========================>getWantAgentCallback=======================>');
......
...@@ -18,14 +18,14 @@ want操作的常数。 ...@@ -18,14 +18,14 @@ want操作的常数。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ------------ | ------------------ | ---------------------- | | ----------------------- | ---------------------------------- | ------------------------------------------------------------------------------ |
| DLP_PARAMS_SANDBOX |ohos.dlp.params.sandbox | 指示沙盒标志的参数的操作。<br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | DLP_PARAMS_SANDBOX | ohos.dlp.params.sandbox | 指示沙盒标志的参数的操作。<br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_BUNDLE_NAME |ohos.dlp.params.bundleName |指示DLP包名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | DLP_PARAMS_BUNDLE_NAME | ohos.dlp.params.bundleName | 指示DLP Bundle名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_MODULE_NAME |ohos.dlp.params.moduleName |指示DLP模块名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | DLP_PARAMS_MODULE_NAME | ohos.dlp.params.moduleName | 指示DLP模块名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_ABILITY_NAME |ohos.dlp.params.abilityName |指示DLP能力名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | DLP_PARAMS_ABILITY_NAME | ohos.dlp.params.abilityName | 指示DLP能力名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_INDEX |ohos.dlp.params.index |指示DLP索引参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | DLP_PARAMS_INDEX | ohos.dlp.params.index | 指示DLP索引参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| ABILITY_BACK_TO_OTHER_MISSION_STACK |ability.params.backToOtherMissionStack |表示该Ability能返回到其它任务栈中。 | | ABILITY_BACK_TO_OTHER_MISSION_STACK | ability.params.backToOtherMissionStack | 表示是否支持跨任务链返回。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
## wantConstant.Flags ## wantConstant.Flags
......
...@@ -35,14 +35,15 @@ deleteForm(formId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -35,14 +35,15 @@ deleteForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 201 | Permissions denied. | | 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 202 | The application is not a system application. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -97,7 +98,8 @@ deleteForm(formId: string): Promise&lt;void&gt; ...@@ -97,7 +98,8 @@ deleteForm(formId: string): Promise&lt;void&gt;
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**参数:** **参数:**
...@@ -143,7 +145,8 @@ releaseForm(formId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -143,7 +145,8 @@ releaseForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -190,7 +193,8 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback&lt; ...@@ -190,7 +193,8 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback&lt;
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -242,7 +246,8 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise&lt;void&gt; ...@@ -242,7 +246,8 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise&lt;void&gt;
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -288,7 +293,8 @@ requestForm(formId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -288,7 +293,8 @@ requestForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -339,7 +345,8 @@ requestForm(formId: string): Promise&lt;void&gt; ...@@ -339,7 +345,8 @@ requestForm(formId: string): Promise&lt;void&gt;
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -386,7 +393,8 @@ castToNormalForm(formId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -386,7 +393,8 @@ castToNormalForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. | | 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -437,7 +445,8 @@ castToNormalForm(formId: string): Promise&lt;void&gt; ...@@ -437,7 +445,8 @@ castToNormalForm(formId: string): Promise&lt;void&gt;
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. | | 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -481,7 +490,8 @@ notifyVisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void ...@@ -481,7 +490,8 @@ notifyVisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -530,7 +540,8 @@ notifyVisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt; ...@@ -530,7 +540,8 @@ notifyVisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt;
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -574,7 +585,8 @@ notifyInvisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;vo ...@@ -574,7 +585,8 @@ notifyInvisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;vo
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -623,7 +635,8 @@ notifyInvisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt; ...@@ -623,7 +635,8 @@ notifyInvisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt;
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -668,7 +681,8 @@ enableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void& ...@@ -668,7 +681,8 @@ enableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void&
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -718,7 +732,8 @@ enableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt; ...@@ -718,7 +732,8 @@ enableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt;
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -764,7 +779,8 @@ disableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void ...@@ -764,7 +779,8 @@ disableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -815,7 +831,8 @@ disableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt; ...@@ -815,7 +831,8 @@ disableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt;
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -852,7 +869,8 @@ isSystemReady(callback: AsyncCallback&lt;void&gt;): void ...@@ -852,7 +869,8 @@ isSystemReady(callback: AsyncCallback&lt;void&gt;): void
| -------- | -------- | | -------- | -------- |
| 202 | The application is not a system application. | | 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -888,7 +906,8 @@ isSystemReady(): Promise&lt;void&gt; ...@@ -888,7 +906,8 @@ isSystemReady(): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 202 | The application is not a system application. | | 202 | The application is not a system application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -925,7 +944,8 @@ getAllFormsInfo(callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): ...@@ -925,7 +944,8 @@ getAllFormsInfo(callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;):
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**参数:** **参数:**
...@@ -968,7 +988,8 @@ getAllFormsInfo(): Promise&lt;Array&lt;formInfo.FormInfo&gt;&gt; ...@@ -968,7 +988,8 @@ getAllFormsInfo(): Promise&lt;Array&lt;formInfo.FormInfo&gt;&gt;
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**返回值:** **返回值:**
...@@ -1018,7 +1039,8 @@ getFormsInfo(bundleName: string, callback: AsyncCallback&lt;Array&lt;formInfo.Fo ...@@ -1018,7 +1039,8 @@ getFormsInfo(bundleName: string, callback: AsyncCallback&lt;Array&lt;formInfo.Fo
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1065,7 +1087,8 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback&lt; ...@@ -1065,7 +1087,8 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback&lt;
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1117,7 +1140,8 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise&lt;Array&lt;formI ...@@ -1117,7 +1140,8 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise&lt;Array&lt;formI
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1160,7 +1184,8 @@ deleteInvalidForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;numb ...@@ -1160,7 +1184,8 @@ deleteInvalidForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;numb
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1211,7 +1236,8 @@ deleteInvalidForms(formIds: Array&lt;string&gt;): Promise&lt;number&gt; ...@@ -1211,7 +1236,8 @@ deleteInvalidForms(formIds: Array&lt;string&gt;): Promise&lt;number&gt;
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1256,7 +1282,8 @@ acquireFormState(want: Want, callback: AsyncCallback&lt;formInfo.FormStateInfo&g ...@@ -1256,7 +1282,8 @@ acquireFormState(want: Want, callback: AsyncCallback&lt;formInfo.FormStateInfo&g
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1317,7 +1344,8 @@ acquireFormState(want: Want): Promise&lt;formInfo.FormStateInfo&gt; ...@@ -1317,7 +1344,8 @@ acquireFormState(want: Want): Promise&lt;formInfo.FormStateInfo&gt;
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1364,7 +1392,8 @@ on(type: 'formUninstall', callback: Callback&lt;string&gt;): void ...@@ -1364,7 +1392,8 @@ on(type: 'formUninstall', callback: Callback&lt;string&gt;): void
| -------- | -------- | | -------- | -------- |
| 202 | The application is not a system application. | | 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1396,7 +1425,8 @@ off(type: 'formUninstall', callback?: Callback&lt;string&gt;): void ...@@ -1396,7 +1425,8 @@ off(type: 'formUninstall', callback?: Callback&lt;string&gt;): void
| -------- | -------- | | -------- | -------- |
| 202 | The application is not a system application. | | 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1436,7 +1466,8 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean, callback: A ...@@ -1436,7 +1466,8 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean, callback: A
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1487,7 +1518,8 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean): Promise&lt ...@@ -1487,7 +1518,8 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean): Promise&lt
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1533,7 +1565,8 @@ notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean, c ...@@ -1533,7 +1565,8 @@ notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean, c
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1584,7 +1617,8 @@ notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean): ...@@ -1584,7 +1617,8 @@ notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean):
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1629,7 +1663,8 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback&lt;void&gt;) ...@@ -1629,7 +1663,8 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback&lt;void&gt;)
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1681,7 +1716,8 @@ shareForm(formId: string, deviceId: string): Promise&lt;void&gt; ...@@ -1681,7 +1716,8 @@ shareForm(formId: string, deviceId: string): Promise&lt;void&gt;
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**参数:** **参数:**
...@@ -1725,7 +1761,8 @@ notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callb ...@@ -1725,7 +1761,8 @@ notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callb
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 | |
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1746,7 +1783,7 @@ try { ...@@ -1746,7 +1783,7 @@ try {
## notifyFormsPrivacyProtected ## notifyFormsPrivacyProtected
function notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: boolean): Promise\<void\>; notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: boolean): Promise\<void\>;
通知指定卡片隐私保护状态改变。使用Promise异步回调。 通知指定卡片隐私保护状态改变。使用Promise异步回调。
...@@ -1777,7 +1814,8 @@ function notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: bool ...@@ -1777,7 +1814,8 @@ function notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: bool
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 | |
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
```ts ```ts
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
......
...@@ -18,6 +18,8 @@ import formInfo from '@ohos.app.form.formInfo'; ...@@ -18,6 +18,8 @@ import formInfo from '@ohos.app.form.formInfo';
**系统能力**:SystemCapability.Ability.Form **系统能力**:SystemCapability.Ability.Form
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ | | ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
| bundleName | string | 是 | 否 | 卡片所属包的包名。 | | bundleName | string | 是 | 否 | 卡片所属包的包名。 |
...@@ -136,5 +138,6 @@ import formInfo from '@ohos.app.form.formInfo'; ...@@ -136,5 +138,6 @@ import formInfo from '@ohos.app.form.formInfo';
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ----------- | ---- | ------------ | | ----------- | ---- | ------------ |
| UNKNOWN | 0 | 表示卡片为未知。 |
| FORM_VISIBLE | 1 | 表示卡片为可见。 | | FORM_VISIBLE | 1 | 表示卡片为可见。 |
| FORM_INVISIBLE | 2 | 表示卡片为不可见。 | | FORM_INVISIBLE | 2 | 表示卡片为不可见。 |
\ No newline at end of file
...@@ -39,7 +39,8 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l ...@@ -39,7 +39,8 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. | | 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -91,7 +92,8 @@ setFormNextRefreshTime(formId: string, minute: number): Promise&lt;void&gt; ...@@ -91,7 +92,8 @@ setFormNextRefreshTime(formId: string, minute: number): Promise&lt;void&gt;
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. | | 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -135,12 +137,14 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call ...@@ -135,12 +137,14 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formBindingData from '@ohos.application.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
var formId = '12400633174999288'; var formId = '12400633174999288';
try { try {
let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'}); let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
...@@ -188,14 +192,16 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr ...@@ -188,14 +192,16 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formBindingData from '@ohos.application.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
var formId = '12400633174999288';
let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'}); let formId = '12400633174999288';
let obj = formBindingData.createFormBindingData({ temperature: '22c', time: '22:00' });
try { try {
formProvider.updateForm(formId, obj).then(() => { formProvider.updateForm(formId, obj).then(() => {
console.log('formProvider updateForm success'); console.log('formProvider updateForm success');
...@@ -228,7 +234,8 @@ getFormsInfo(callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): voi ...@@ -228,7 +234,8 @@ getFormsInfo(callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): voi
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -269,7 +276,8 @@ getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback&lt;Array&l ...@@ -269,7 +276,8 @@ getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback&lt;Array&l
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -321,7 +329,8 @@ getFormsInfo(filter?: formInfo.FormInfoFilter): Promise&lt;Array&lt;formInfo.For ...@@ -321,7 +329,8 @@ getFormsInfo(filter?: formInfo.FormInfoFilter): Promise&lt;Array&lt;formInfo.For
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -370,13 +379,15 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, ...@@ -370,13 +379,15 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData,
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formBindingData from '@ohos.application.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
var want = {
let want = {
abilityName: 'FormAbility', abilityName: 'FormAbility',
parameters: { parameters: {
'ohos.extra.param.key.form_dimension': 2, 'ohos.extra.param.key.form_dimension': 2,
...@@ -424,12 +435,13 @@ requestPublishForm(want: Want, callback: AsyncCallback&lt;string&gt;): void ...@@ -424,12 +435,13 @@ requestPublishForm(want: Want, callback: AsyncCallback&lt;string&gt;): void
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
var want = { let want = {
abilityName: 'FormAbility', abilityName: 'FormAbility',
parameters: { parameters: {
'ohos.extra.param.key.form_dimension': 2, 'ohos.extra.param.key.form_dimension': 2,
...@@ -483,12 +495,13 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData ...@@ -483,12 +495,13 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
var want = { let want = {
abilityName: 'FormAbility', abilityName: 'FormAbility',
parameters: { parameters: {
'ohos.extra.param.key.form_dimension': 2, 'ohos.extra.param.key.form_dimension': 2,
...@@ -531,7 +544,8 @@ isRequestPublishFormSupported(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -531,7 +544,8 @@ isRequestPublishFormSupported(callback: AsyncCallback&lt;boolean&gt;): void
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -593,7 +607,8 @@ isRequestPublishFormSupported(): Promise&lt;boolean&gt; ...@@ -593,7 +607,8 @@ isRequestPublishFormSupported(): Promise&lt;boolean&gt;
| 202 | The application is not a system application. | | 202 | The application is not a system application. |
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
......
...@@ -389,7 +389,11 @@ killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\> ...@@ -389,7 +389,11 @@ killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\>
切断account进程(Promise形式)。 切断account进程(Promise形式)。
**需要权限**:ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS, ohos.permission.CLEAN_BACKGROUND_PROCESSES > **说明:**
>
> 当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
...@@ -423,11 +427,15 @@ killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCal ...@@ -423,11 +427,15 @@ killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCal
切断account进程(callback形式)。 切断account进程(callback形式)。
> **说明:**
>
> 当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**: 此接口为系统接口,三方应用不支持调用。 **系统API**: 此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS, ohos.permission.CLEAN_BACKGROUND_PROCESSES **需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**参数:** **参数:**
......
...@@ -3,9 +3,16 @@ ...@@ -3,9 +3,16 @@
定义环境变化信息。Configuration是接口定义,仅做字段声明。 定义环境变化信息。Configuration是接口定义,仅做字段声明。
> **说明:** > **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块从API version 9废弃,替换模块为[@ohos.app.ability.Configuration (Configuration)](js-apis-app-ability-configuration.md) > 本模块从API version 9废弃,替换模块为[@ohos.app.ability.Configuration (Configuration)](js-apis-app-ability-configuration.md)
## 导入模块
```ts
import Configuration from '@ohos.app.application.Configuration';
```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
......
...@@ -360,7 +360,7 @@ continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback, callba ...@@ -360,7 +360,7 @@ continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback, callba
迁移任务,以回调函数的方式返回。 迁移任务,以回调函数的方式返回。
**需要权限**:ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC **需要权限**:ohos.permission.MANAGE_MISSIONSohos.permission.DISTRIBUTED_DATASYNC
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
...@@ -418,7 +418,7 @@ continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promi ...@@ -418,7 +418,7 @@ continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promi
迁移任务,以promise方式返回执行结果。 迁移任务,以promise方式返回执行结果。
**需要权限**:ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC **需要权限**:ohos.permission.MANAGE_MISSIONSohos.permission.DISTRIBUTED_DATASYNC
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
在连接指定的后台服务时作为入参用于接收连接过程中的状态变化,如作为[connectServiceExtensionAbility](js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextconnectserviceextensionability)的入参连接指定的ServiceExtensionAbility。 在连接指定的后台服务时作为入参用于接收连接过程中的状态变化,如作为[connectServiceExtensionAbility](js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextconnectserviceextensionability)的入参连接指定的ServiceExtensionAbility。
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
......
...@@ -110,7 +110,7 @@ let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelpe ...@@ -110,7 +110,7 @@ let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelpe
function onChangeNotify() { function onChangeNotify() {
console.info('==========================>onChangeNotify=======================>'); console.info('==========================>onChangeNotify=======================>');
}; };
helper.on( DAHelper.on(
'dataChange', 'dataChange',
'dataability:///com.example.DataAbility', 'dataability:///com.example.DataAbility',
onChangeNotify onChangeNotify
...@@ -143,11 +143,11 @@ let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelpe ...@@ -143,11 +143,11 @@ let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelpe
function onChangeNotify() { function onChangeNotify() {
console.info('==========================>onChangeNotify=======================>'); console.info('==========================>onChangeNotify=======================>');
}; };
helper.off( DAHelper.off(
'dataChange', 'dataChange',
'dataability:///com.example.DataAbility', 'dataability:///com.example.DataAbility',
); );
helper.off( DAHelper.off(
'dataChange', 'dataChange',
'dataability:///com.example.DataAbility', 'dataability:///com.example.DataAbility',
onChangeNotify onChangeNotify
...@@ -420,7 +420,7 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -420,7 +420,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper(
'dataability:///com.example.DataAbility' 'dataability:///com.example.DataAbility'
); );
helper.notifyChange('dataability:///com.example.DataAbility', (err) => { DAHelper.notifyChange('dataability:///com.example.DataAbility', (err) => {
console.info('==========================>Called=======================>'); console.info('==========================>Called=======================>');
}); });
``` ```
......
...@@ -106,7 +106,7 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -106,7 +106,7 @@ import featureAbility from '@ohos.ability.featureAbility';
import bundle from '@ohos.bundle.bundleManager'; import bundle from '@ohos.bundle.bundleManager';
let context: featureAbility.Context = featureAbility.getContext(); let context: featureAbility.Context = featureAbility.getContext();
bundle.getBundleInfo('com.context.test', 1, (err, datainfo) =>{ bundle.getBundleInfo('com.context.test', 1, (err, datainfo) =>{
context.verifyPermission('com.example.permission', {uid:datainfo.uid}, (err, data) =>{ context.verifyPermission('com.example.permission', {uid:datainfo.appInfo.uid}, (err, data) =>{
console.info('verifyPermission err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); console.info('verifyPermission err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data));
}); });
}); });
......
...@@ -32,7 +32,5 @@ import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry ...@@ -32,7 +32,5 @@ import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry
**示例:** **示例:**
```ts ```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
let args: AbilityDelegatorRegistry.AbilityDelegatorArgs = AbilityDelegatorRegistry.getArguments(); let args: AbilityDelegatorRegistry.AbilityDelegatorArgs = AbilityDelegatorRegistry.getArguments();
``` ```
...@@ -37,8 +37,6 @@ Ability监听器 ...@@ -37,8 +37,6 @@ Ability监听器
**示例:** **示例:**
```ts ```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback'); console.info('onAbilityCreateCallback');
} }
......
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
提供用于匹配满足指定条件的受监视的AbilityStage对象的方法。最近匹配的AbilityStage对象将保存在AbilityStageMonitor对象中。 提供用于匹配满足指定条件的受监视的AbilityStage对象的方法。最近匹配的AbilityStage对象将保存在AbilityStageMonitor对象中。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ | | ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ |
| moduleName<sup>9+</sup> | string | 是 | 是 | 要监视的abilityStage的模块名。 | | moduleName | string | 是 | 是 | 要监视的abilityStage的模块名。 |
| srcEntrance<sup>9+</sup> | string | 是 | 是 | 要监视的abilityStage的源路径。 | | srcEntrance | string | 是 | 是 | 要监视的abilityStage的源路径。 |
**示例:** **示例:**
```ts ```ts
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
定义Ability状态信息,可以通过[registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8)注册生命周期变化监听后,通过[ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md)的onAbilityStateChanged生命周期回调获取。 定义Ability状态信息,可以通过[registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8)注册生命周期变化监听后,通过[ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md)的onAbilityStateChanged生命周期回调获取。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
...@@ -12,11 +16,30 @@ import appManager from '@ohos.application.appManager'; ...@@ -12,11 +16,30 @@ import appManager from '@ohos.application.appManager';
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------------------- | ---------| ---- | ---- | ------------------------- | | ----------------------- | ---------| ---- | ---- | ------------------------- |
| pid<sup>8+</sup> | number | 是 | 否 | 进程ID。 | | pid | number | 是 | 否 | 进程ID。 |
| bundleName<sup>8+</sup> | string | 是 | 否 | 应用包名。 | | bundleName | string | 是 | 否 | 应用Bundle名称。 |
| abilityName<sup>8+</sup> | string | 是 | 否 | Ability名称。 | | abilityName | string | 是 | 否 | Ability名称。 |
| uid<sup>8+</sup> | number | 是 | 否 | 用户ID。 | | uid | number | 是 | 否 | 用户ID。 |
| state<sup>8+</sup> | number | 是 | 否 | Ability状态。 | | state | number | 是 | 否 | [Ability状态](#ability状态)。 |
| moduleName<sup>9+</sup> | string | 是 | 否 | Ability所属的HAP包的名称。 | | moduleName<sup>9+</sup> | string | 是 | 否 | Ability所属的HAP的名称。 |
| abilityType<sup>8+</sup> | string | 是 | 否 | Ability类型:页面或服务等。 | | abilityType | number | 是 | 否 | [Ability类型](#ability类型):页面或服务等。 |
#### Ability状态
| 值 | 状态 | 说明 |
| ---- | -------------------------- | ---------------------- |
| 0 | ABILITY_STATE_CREATE | Ability正在创建中 |
| 1 | ABILITY_STATE_READY | Ability已创建完成 |
| 2 | ABILITY_STATE_FOREGROUND | Ability处于前台 |
| 3 | ABILITY_STATE_FOCUS | Ability已经获焦 |
| 4 | ABILITY_STATE_BACKGROUND | Ability处于后台 |
| 5 | ABILITY_STATE_TERMINATED | Ability已经销毁 |
| 8 | ABILITY_STATE_CONNECTED | 后台服务已被客户端连接 |
| 9 | ABILITY_STATE_DISCONNECTED | 后台服务客户端断开连接 |
#### Ability类型
| 值 | 状态 | 说明 |
| ---- | ------- | --------------------- |
| 0 | UNKNOWN | 未知类型 |
| 1 | PAGE | UI界面类型的Ability |
| 2 | SERVICE | 后台服务类型的Ability |
\ No newline at end of file
...@@ -301,7 +301,6 @@ getRunningProcessInformation(): Promise\<Array\<ProcessInformation>>; ...@@ -301,7 +301,6 @@ getRunningProcessInformation(): Promise\<Array\<ProcessInformation>>;
**示例:** **示例:**
```ts ```ts
let applicationContext = this.context.getApplicationContext();
applicationContext.getRunningProcessInformation().then((data) => { applicationContext.getRunningProcessInformation().then((data) => {
console.log('The process running information is:' + JSON.stringify(data)); console.log('The process running information is:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -339,7 +338,6 @@ getRunningProcessInformation(callback: AsyncCallback\<Array\<ProcessInformation> ...@@ -339,7 +338,6 @@ getRunningProcessInformation(callback: AsyncCallback\<Array\<ProcessInformation>
**示例:** **示例:**
```ts ```ts
let applicationContext = this.context.getApplicationContext();
applicationContext.getRunningProcessInformation((err, data) => { applicationContext.getRunningProcessInformation((err, data) => {
if (err.code !== 0) { if (err.code !== 0) {
console.error('getRunningProcessInformation faile, err: ' + JSON.stringify(err)); console.error('getRunningProcessInformation faile, err: ' + JSON.stringify(err));
...@@ -407,10 +405,16 @@ killProcessesBySelf(callback: AsyncCallback\<void>); ...@@ -407,10 +405,16 @@ killProcessesBySelf(callback: AsyncCallback\<void>);
**示例:** **示例:**
```ts ```ts
<<<<<<< HEAD
let applicationContext = this.context.getApplicationContext(); let applicationContext = this.context.getApplicationContext();
applicationContext.killProcessesBySelf(err => { applicationContext.killProcessesBySelf(err => {
if (err.code !== 0) { if (err.code !== 0) {
console.error('killProcessesBySelf faile, err: ' + JSON.stringify(err)); console.error('killProcessesBySelf faile, err: ' + JSON.stringify(err));
=======
applicationContext.killAllProcesses(error => {
if (error) {
console.error('killAllProcesses fail, error: ${JSON.stringify(error)}');
>>>>>>> 9643df3c1b (Fix document consistency issues of ability)
} }
}) })
``` ```
\ No newline at end of file
...@@ -2,10 +2,14 @@ ...@@ -2,10 +2,14 @@
定义应用状态监听,可以作为[registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8)的入参监听当前应用的生命周期变化。 定义应用状态监听,可以作为[registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8)的入参监听当前应用的生命周期变化。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
import appManager from '@ohos.application.appManager'; import appManager from '@ohos.app.ability.appManager';
``` ```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
...@@ -14,16 +18,14 @@ import appManager from '@ohos.application.appManager'; ...@@ -14,16 +18,14 @@ import appManager from '@ohos.application.appManager';
| 名称 | | 类型 | 可读 | 可写 | 说明 | | 名称 | | 类型 | 可读 | 可写 | 说明 |
| ----------------------- | ---------| ---- | ---- | ------------------------- | ------------------------- | | ----------------------- | ---------| ---- | ---- | ------------------------- | ------------------------- |
| onForegroundApplicationChanged<sup>8+</sup> | [AppStateData](js-apis-inner-application-appStateData.md) | AsyncCallback\<void> | 是 | 否 | 应用前后台状态发生变化时执行的回调函数。 | | onForegroundApplicationChanged | [AppStateData](js-apis-inner-application-appStateData.md) | AsyncCallback\<void> | 是 | 否 | 应用前后台状态发生变化时执行的回调函数。 |
| onAbilityStateChanged<sup>8+</sup> | [AbilityStateData](js-apis-inner-application-abilityStateData.md) | AsyncCallback\<void> | 是 | 否 | ability状态发生变化时执行的回调函数。 | | onAbilityStateChanged | [AbilityStateData](js-apis-inner-application-abilityStateData.md) | AsyncCallback\<void> | 是 | 否 | ability状态发生变化时执行的回调函数。 |
| onProcessCreated<sup>8+</sup> | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | 是 | 否 | 进程创建时执行的回调函数。 | | onProcessCreated | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | 是 | 否 | 进程创建时执行的回调函数。 |
| onProcessDied<sup>8+</sup> | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | 是 | 否 | 进程销毁时执行的回调函数。 | | onProcessDied | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | 是 | 否 | 进程销毁时执行的回调函数。 |
| onProcessStateChanged<sup>8+</sup> | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | 是 | 否 | 进程状态更新时执行的回调函数。 | | onProcessStateChanged<sup>9+</sup> | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | 是 | 否 | 进程状态更新时执行的回调函数。 |
**示例:** **示例:**
```ts ```ts
import appManager from "@ohos.application.appManager";
let applicationStateObserver = { let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) { onForegroundApplicationChanged(appStateData) {
console.log('onForegroundApplicationChanged appStateData: ' + JSON.stringify(appStateData)); console.log('onForegroundApplicationChanged appStateData: ' + JSON.stringify(appStateData));
......
...@@ -122,16 +122,12 @@ createModuleContext(bundleName: string, moduleName: string): Context; ...@@ -122,16 +122,12 @@ createModuleContext(bundleName: string, moduleName: string): Context;
**示例:** **示例:**
```ts ```ts
<<<<<<< HEAD
let moduleContext = this.context.createModuleContext('com.example.test', 'entry');
=======
let moduleContext: common.Context; let moduleContext: common.Context;
try { try {
moduleContext = this.context.createModuleContext('com.example.test', 'entry'); moduleContext = this.context.createModuleContext('com.example.test', 'entry');
} catch (error) { } catch (error) {
console.error('createModuleContext failed, error.code: ${error.code}, error.message: ${error.message}'); console.error('createModuleContext failed, error.code: ${error.code}, error.message: ${error.message}');
} }
>>>>>>> 48a75c8e72 (Modify the secondary import module of ability)
``` ```
## Context.getApplicationContext ## Context.getApplicationContext
...@@ -151,16 +147,12 @@ getApplicationContext(): ApplicationContext; ...@@ -151,16 +147,12 @@ getApplicationContext(): ApplicationContext;
**示例:** **示例:**
```ts ```ts
<<<<<<< HEAD
let applicationContext = this.context.getApplicationContext();
=======
let applicationContext: common.Context; let applicationContext: common.Context;
try { try {
applicationContext = this.context.getApplicationContext(); applicationContext = this.context.getApplicationContext();
} catch (error) { } catch (error) {
console.error('getApplicationContext failed, error.code: ${error.code}, error.message: ${error.message}'); console.error('getApplicationContext failed, error.code: ${error.code}, error.message: ${error.message}');
} }
>>>>>>> 48a75c8e72 (Modify the secondary import module of ability)
``` ```
## AreaMode ## AreaMode
......
# ContinueCallback # ContinueCallback
表示迁移完成后,返回迁移结果回调函数,可以作为[continueMission](js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission)的入参监听迁移回调。 表示跨设备迁移Mission完成后,返回迁移结果的回调函数,迁移Mission详见:[continueMission接口](js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission)
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## ContinueCallback.onContinueDone
onContinueDone(result: number): void;
Mission迁移完成后调用,返回迁移结果。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
表示发起任务迁移时所需参数的枚举,可以作为[continueMission](js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission)的入参指定迁移相关参数。 表示发起任务迁移时所需参数的枚举,可以作为[continueMission](js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission)的入参指定迁移相关参数。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
定义异常监听,可以作为[errorManager.on](js-apis-app-ability-errorManager.md#errormanageron)的入参监听当前应用发生的异常。 定义异常监听,可以作为[errorManager.on](js-apis-app-ability-errorManager.md#errormanageron)的入参监听当前应用发生的异常。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
...@@ -28,9 +32,15 @@ onUnhandledException(errMsg: string): void; ...@@ -28,9 +32,15 @@ onUnhandledException(errMsg: string): void;
import errorManager from '@ohos.app.ability.errorManager'; import errorManager from '@ohos.app.ability.errorManager';
let observer = { let observer = {
onUnhandledException(errorMsg) { onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ' + JSON.stringify(errorMsg)); console.error('onUnhandledException, errorMsg: ', errorMsg);
} }
}; };
errorManager.on('error',observer);
try {
errorManager.on('error', observer);
} catch (error) {
console.error('registerErrorObserver failed, error.code: ${error.code}, error.message: ${error.message}');
}
```
``` ```
\ No newline at end of file
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
作为可以[registerMissionListener](js-apis-distributedMissionManager.md#distributedmissionmanagerregistermissionlistener)的入参,表示开始同步后,建立的回调函数。 作为可以[registerMissionListener](js-apis-distributedMissionManager.md#distributedmissionmanagerregistermissionlistener)的入参,表示开始同步后,建立的回调函数。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
表示Ability对应的任务信息,可以通过[getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo)获取。 表示Ability对应的任务信息,可以通过[getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo)获取。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
定义系统任务状态监听,可以通过[registerMissionListener](js-apis-application-missionManager.md#missionmanagerregistermissionlistener)注册。 定义系统任务状态监听,可以通过[registerMissionListener](js-apis-application-missionManager.md#missionmanagerregistermissionlistener)注册。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
...@@ -16,9 +20,9 @@ import missionManager from '@ohos.app.ability.missionManager'; ...@@ -16,9 +20,9 @@ import missionManager from '@ohos.app.ability.missionManager';
| onMissionDestroyed | function | 否 | 表示当系统销毁任务时回调执行。 | | onMissionDestroyed | function | 否 | 表示当系统销毁任务时回调执行。 |
| onMissionSnapshotChanged | function | 否 | 表示当系统更新任务缩略图时回调执行。 | | onMissionSnapshotChanged | function | 否 | 表示当系统更新任务缩略图时回调执行。 |
| onMissionMovedToFront | function | 否 | 表示当系统将任务移动到前台时回调执行。 | | onMissionMovedToFront | function | 否 | 表示当系统将任务移动到前台时回调执行。 |
| onMissionLabelUpdated | function | 否 | 表示当系统更新任务标签时回调执行。 | | onMissionLabelUpdated<sup>9+</sup> | function | 否 | 表示当系统更新任务标签时回调执行。 |
| onMissionIconUpdated | function | 否 | 表示当系统更新任务图标时回调执行。 | | onMissionIconUpdated<sup>9+</sup> | function | 否 | 表示当系统更新任务图标时回调执行。 |
| onMissionClosed | function | 否 | 表示当系统关闭任务时回调执行。 | | onMissionClosed<sup>9+</sup> | function | 否 | 表示当系统关闭任务时回调执行。 |
**示例:** **示例:**
```ts ```ts
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
作为[startSyncRemoteMissions](js-apis-distributedMissionManager.md#distributedmissionmanagerstartsyncremotemissions)的入参,表示同步时所需参数的枚举。 作为[startSyncRemoteMissions](js-apis-distributedMissionManager.md#distributedmissionmanagerstartsyncremotemissions)的入参,表示同步时所需参数的枚举。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
......
...@@ -2,10 +2,14 @@ ...@@ -2,10 +2,14 @@
定义进程数据,可以通过[registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8)注册生命周期变化监听后,通过[ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md)的onProcessCreated生命周期回调获取。 定义进程数据,可以通过[registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8)注册生命周期变化监听后,通过[ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md)的onProcessCreated生命周期回调获取。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
import appManager from '@ohos.app.ability.appManager'; import appManager from '@ohos.application.appManager';
``` ```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
...@@ -14,11 +18,12 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -14,11 +18,12 @@ import appManager from '@ohos.app.ability.appManager';
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------------------- | ---------| ---- | ---- | ------------------------- | | ----------------------- | ---------| ---- | ---- | ------------------------- |
| pid<sup>8+</sup> | number | 是 | 否 | 进程ID。 | | pid | number | 是 | 否 | 进程ID。 |
| bundleName<sup>8+</sup> | string | 是 | 否 | 应用包名。 | | bundleName | string | 是 | 否 | 应用包名。 |
| uid<sup>8+</sup> | number | 是 | 否 | 用户ID。 | | uid | number | 是 | 否 | 应用的uid。 |
| isContinuousTask<sup>9+</sup> | boolean | 是 | 否 | 判断过程是否为连续任务。 | | isContinuousTask<sup>9+</sup> | boolean | 是 | 否 | 是否为长时任务,true表示是,false表示不是 |
| isKeepAlive<sup>9+</sup> | boolean | 是 | 否 | 判断该过程是否保持活跃。 | | isKeepAlive<sup>9+</sup> | boolean | 是 | 否 | 是否为常驻进程,true表示是,false表示不是 |
| state<sup>9+</sup> | number | 是 | 否 | 应用的状态,取值及对应的状态为:0(刚创建),2(前台),4(后台),5(已终止)。 |
**示例:** **示例:**
```ts ```ts
......
...@@ -25,7 +25,6 @@ import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry ...@@ -25,7 +25,6 @@ import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry
**示例:** **示例:**
```ts ```ts
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator; let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator;
let cmd = 'cmd'; let cmd = 'cmd';
......
...@@ -366,23 +366,20 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback ...@@ -366,23 +366,20 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
windowMode: 0, windowMode: 0,
}; };
try { try {
this.context.startAbilityForResult(want, options, (error, result) => { this.context.startAbilityForResult(want, options, (err, result) => {
if (error.code) { if (err.code) {
// 处理业务逻辑错误 // 处理业务逻辑错误
console.log('startAbilityForResult failed, error.code: ' + JSON.stringify(error.code) + console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`);
' error.message: ' + JSON.stringify(error.message)); return;
return; }
} // 执行正常业务
// 执行正常业务 console.info('startAbilityForResult succeed');
console.log('startAbilityForResult succeed, result.resultCode = ' + });
result.resultCode) } catch (err) {
}); // 处理入参错误异常
} catch (paramError) { console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`);
// 处理入参错误异常 }
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
``` ```
...@@ -785,22 +782,20 @@ startServiceExtensionAbility(want: Want): Promise\<void>; ...@@ -785,22 +782,20 @@ startServiceExtensionAbility(want: Want): Promise\<void>;
abilityName: 'MainAbility' abilityName: 'MainAbility'
}; };
try { try {
this.context.startServiceExtensionAbility(want) this.context.startServiceExtensionAbility(want)
.then((data) => { .then(() => {
// 执行正常业务 // 执行正常业务
console.log('startServiceExtensionAbility succeed'); console.info('startServiceExtensionAbility succeed');
}) })
.catch((error) => { .catch((err) => {
// 处理业务逻辑错误 // 处理业务逻辑错误
console.log('startServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) + console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
' error.message: ' + JSON.stringify(error.message)); });
}); } catch (err) {
} catch (paramError) { // 处理入参错误异常
// 处理入参错误异常 console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
console.log('error.code: ' + JSON.stringify(paramError.code) + }
' error.message: ' + JSON.stringify(paramError.message));
}
``` ```
## UIAbilityContext.startServiceExtensionAbilityWithAccount ## UIAbilityContext.startServiceExtensionAbilityWithAccount
...@@ -1410,15 +1405,22 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; ...@@ -1410,15 +1405,22 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
**示例:** **示例:**
```ts ```ts
let want = { let want = {
deviceId: '', deviceId: '',
bundleName: 'com.extreme.test', bundleName: 'com.example.myapplication',
abilityName: 'MainAbility' abilityName: 'ServiceExtensionAbility'
}; };
let options = { let commRemote;
onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, let options = {
onDisconnect(elementName) { console.log('----------- onDisconnect -----------') }, onConnect(elementName, remote) {
onFailed(code) { console.log('----------- onFailed -----------') } commRemote = remote;
console.info('onConnect...')
},
onDisconnect(elementName) {
console.info('onDisconnect...')
},
onFailed(code) {
console.info('onFailed...')
} }
let connection = null; let connection = null;
...@@ -1472,16 +1474,23 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options ...@@ -1472,16 +1474,23 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
**示例:** **示例:**
```ts ```ts
let want = { let want = {
deviceId: '', deviceId: '',
bundleName: 'com.extreme.test', bundleName: 'com.example.myapplication',
abilityName: 'MainAbility' abilityName: 'ServiceExtensionAbility'
}; };
let accountId = 100; let accountId = 100;
let options = { let commRemote;
onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, let options = {
onDisconnect(elementName) { console.log('----------- onDisconnect -----------') }, onConnect(elementName, remote) {
onFailed(code) { console.log('----------- onFailed -----------') } commRemote = remote;
console.info('onConnect...')
},
onDisconnect(elementName) {
console.info('onDisconnect...')
},
onFailed(code) {
console.info('onFailed...')
} }
let connection = null; let connection = null;
...@@ -1526,8 +1535,8 @@ disconnectServiceExtensionAbility(connection: number): Promise\<void>; ...@@ -1526,8 +1535,8 @@ disconnectServiceExtensionAbility(connection: number): Promise\<void>;
**示例:** **示例:**
```ts ```ts
// connection为connectServiceExtensionAbility中的返回值 // connection为connectServiceExtensionAbility中的返回值
let connection = 1; let connection = 1;
try { try {
this.context.disconnectServiceExtensionAbility(connection) this.context.disconnectServiceExtensionAbility(connection)
...@@ -1574,8 +1583,26 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback\<vo ...@@ -1574,8 +1583,26 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback\<vo
**示例:** **示例:**
```ts ```ts
// connection为connectServiceExtensionAbility中的返回值 // connection为connectServiceExtensionAbility中的返回值
let connection = 1; let connection = 1;
let commRemote;
try {
this.context.disconnectServiceExtensionAbility(connection, (err) => {
commRemote = null;
if (err.code) {
// 处理业务逻辑错误
console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
return;
}
// 执行正常业务
console.info('disconnectServiceExtensionAbility succeed');
});
} catch (err) {
commRemote = null;
// 处理入参错误异常
console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}
try { try {
this.context.disconnectServiceExtensionAbility(connection, (error) => { this.context.disconnectServiceExtensionAbility(connection, (error) => {
...@@ -1931,7 +1958,7 @@ requestPermissionsFromUser(permissions: Array&lt;string&gt;, requestCallback: As ...@@ -1931,7 +1958,7 @@ requestPermissionsFromUser(permissions: Array&lt;string&gt;, requestCallback: As
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | 是 | 权限列表。 | | permissions | Array&lt;string&gt; | 是 | 权限列表。 |
| callback | AsyncCallback&lt;[PermissionRequestResult](js-apis-permissionRequestResult.md)&gt; | 是 | 回调函数,返回接口调用是否成功的结果。 | | callback | AsyncCallback&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | 是 | 回调函数,返回接口调用是否成功的结果。 |
**示例:** **示例:**
...@@ -1962,7 +1989,7 @@ requestPermissionsFromUser(permissions: Array&lt;string&gt;) : Promise&lt;Permis ...@@ -1962,7 +1989,7 @@ requestPermissionsFromUser(permissions: Array&lt;string&gt;) : Promise&lt;Permis
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;[PermissionRequestResult](js-apis-permissionRequestResult.md)&gt; | 返回一个Promise,包含接口的结果。 | | Promise&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | 返回一个Promise,包含接口的结果。 |
**示例:** **示例:**
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
作为[trigger](js-apis-app-ability-wantAgent.md#wantagenttrigger)的入参定义触发WantAgent所需要的信息。 作为[trigger](js-apis-app-ability-wantAgent.md#wantagenttrigger)的入参定义触发WantAgent所需要的信息。
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
定义触发WantAgent所需要的信息,可以作为[getWantAgent](js-apis-app-ability-wantAgent.md#wantagentgetwantagent)的入参创建指定的WantAgent对象。 定义触发WantAgent所需要的信息,可以作为[getWantAgent](js-apis-app-ability-wantAgent.md#wantagentgetwantagent)的入参创建指定的WantAgent对象。
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
......
...@@ -20,6 +20,8 @@ getWant(agent: WantAgent, callback: AsyncCallback\<Want\>): void ...@@ -20,6 +20,8 @@ getWant(agent: WantAgent, callback: AsyncCallback\<Want\>): void
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -91,6 +93,8 @@ getWant(agent: WantAgent): Promise\<Want\> ...@@ -91,6 +93,8 @@ getWant(agent: WantAgent): Promise\<Want\>
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册