未验证 提交 47dc3ed3 编写于 作者: O openharmony_ci 提交者: Gitee

!15339 翻译完成:14771+14165等 元能力API资料示例代码规范修改

Merge pull request !15339 from wusongqing/TR14771
...@@ -10,7 +10,7 @@ The **Ability** module provides all level-2 module APIs for developers to export ...@@ -10,7 +10,7 @@ The **Ability** module provides all level-2 module APIs for developers to export
## Modules to Import ## Modules to Import
```ts ```ts
import ability from '@ohos.ability.ability' import ability from '@ohos.ability.ability';
``` ```
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
......
# @ohos.ability.dataUriUtils (dataUriUtils) # @ohos.ability.dataUriUtils (DataUriUtils)
The **DataUriUtils** module provides APIs to process URI objects. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI. This module will be replaced by the **app.ability.dataUriUtils** module in the near future. You are advised to use the **[@ohos.app.ability.dataUriUtils](js-apis-app-ability-dataUriUtils.md)** module. The **DataUriUtils** module provides APIs to process URI objects. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI. This module will be replaced by the **app.ability.dataUriUtils** module in the near future. You are advised to use the **[@ohos.app.ability.dataUriUtils](js-apis-app-ability-dataUriUtils.md)** module.
...@@ -35,7 +35,7 @@ Obtains the ID attached to the end of a given URI. ...@@ -35,7 +35,7 @@ Obtains the ID attached to the end of a given URI.
**Example** **Example**
```ts ```ts
let id = dataUriUtils.getId("com.example.dataUriUtils/1221"); let id = dataUriUtils.getId('com.example.dataUriUtils/1221');
``` ```
...@@ -66,9 +66,9 @@ Attaches an ID to the end of a given URI. ...@@ -66,9 +66,9 @@ Attaches an ID to the end of a given URI.
```ts ```ts
let id = 1122; let id = 1122;
let uri = dataUriUtils.attachId( let uri = dataUriUtils.attachId(
"com.example.dataUriUtils", 'com.example.dataUriUtils',
id, id,
) );
``` ```
...@@ -96,7 +96,7 @@ Deletes the ID from the end of a given URI. ...@@ -96,7 +96,7 @@ Deletes the ID from the end of a given URI.
**Example** **Example**
```ts ```ts
let uri = dataUriUtils.deleteId("com.example.dataUriUtils/1221") let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221');
``` ```
...@@ -127,7 +127,7 @@ Updates the ID in a given URI. ...@@ -127,7 +127,7 @@ Updates the ID in a given URI.
```ts ```ts
let id = 1122; let id = 1122;
let uri = dataUriUtils.updateId( let uri = dataUriUtils.updateId(
"com.example.dataUriUtils/1221", 'com.example.dataUriUtils/1221',
id id
) );
``` ```
...@@ -9,7 +9,7 @@ The **ErrorCode** module defines the error codes that may be returned when an ab ...@@ -9,7 +9,7 @@ The **ErrorCode** module defines the error codes that may be returned when an ab
## Modules to Import ## Modules to Import
```ts ```ts
import errorCode from '@ohos.ability.errorCode' import errorCode from '@ohos.ability.errorCode';
``` ```
## ErrorCode ## ErrorCode
......
...@@ -14,7 +14,7 @@ The ParticleAbility module is used to perform operations on abilities of the Dat ...@@ -14,7 +14,7 @@ The ParticleAbility module is used to perform operations on abilities of the Dat
## Modules to Import ## Modules to Import
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
``` ```
## particleAbility.startAbility ## particleAbility.startAbility
...@@ -40,27 +40,27 @@ Observe the following when using this API: ...@@ -40,27 +40,27 @@ Observe the following when using this API:
**Example** **Example**
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
import wantConstant from '@ohos.ability.wantConstant' import wantConstant from '@ohos.ability.wantConstant';
particleAbility.startAbility( particleAbility.startAbility(
{ {
want: want:
{ {
action: "action.system.home", action: 'action.system.home',
entities: ["entity.system.home"], entities: ['entity.system.home'],
type: "MIMETYPE", type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "", deviceId: '',
bundleName: "com.example.Data", bundleName: 'com.example.Data',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
uri: "" uri: ''
}, },
}, },
(error, result) => { (error, result) => {
console.log('particleAbility startAbility errCode:' + error + 'result:' + result) console.error('particleAbility startAbility errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}');
}, },
) );
``` ```
## particleAbility.startAbility ## particleAbility.startAbility
...@@ -91,25 +91,25 @@ Observe the following when using this API: ...@@ -91,25 +91,25 @@ Observe the following when using this API:
**Example** **Example**
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
import wantConstant from '@ohos.ability.wantConstant' import wantConstant from '@ohos.ability.wantConstant';
particleAbility.startAbility( particleAbility.startAbility(
{ {
want: want:
{ {
action: "action.system.home", action: 'action.system.home',
entities: ["entity.system.home"], entities: ['entity.system.home'],
type: "MIMETYPE", type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "", deviceId: '',
bundleName: "com.example.Data", bundleName: 'com.example.Data',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
uri: "" uri: ''
}, },
}, },
).then((data) => { ).then((data) => {
console.info("particleAbility startAbility"); console.info('particleAbility startAbility');
}); });
``` ```
...@@ -130,13 +130,13 @@ Terminates this ParticleAbility. This API uses an asynchronous callback to retur ...@@ -130,13 +130,13 @@ Terminates this ParticleAbility. This API uses an asynchronous callback to retur
**Example** **Example**
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
particleAbility.terminateSelf( particleAbility.terminateSelf(
(error, result) => { (error, result) => {
console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result) console.log('particleAbility terminateSelf errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}');
} }
) );
``` ```
## particleAbility.terminateSelf ## particleAbility.terminateSelf
...@@ -156,10 +156,10 @@ Terminates this ParticleAbility. This API uses a promise to return the result. ...@@ -156,10 +156,10 @@ Terminates this ParticleAbility. This API uses a promise to return the result.
**Example** **Example**
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
particleAbility.terminateSelf().then((data) => { particleAbility.terminateSelf().then((data) => {
console.info("particleAbility terminateSelf"); console.info('particleAbility terminateSelf');
}); });
``` ```
...@@ -194,10 +194,10 @@ Observe the following when using this API: ...@@ -194,10 +194,10 @@ Observe the following when using this API:
**Example** **Example**
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
var uri = ""; let uri = '';
particleAbility.acquireDataAbilityHelper(uri) particleAbility.acquireDataAbilityHelper(uri);
``` ```
...@@ -228,17 +228,17 @@ import wantAgent from '@ohos.app.ability.wantAgent'; ...@@ -228,17 +228,17 @@ import wantAgent from '@ohos.app.ability.wantAgent';
function callback(err, data) { function callback(err, data) {
if (err) { if (err) {
console.error("Operation failed cause: " + JSON.stringify(err)); console.error('Operation failed cause: ${JSON.stringify(err)}');
} else { } else {
console.info("Operation succeeded"); console.info('Operation succeeded');
} }
} }
let wantAgentInfo = { let wantAgentInfo = {
wants: [ wants: [
{ {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility" abilityName: 'EntryAbility'
} }
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
...@@ -248,8 +248,8 @@ let wantAgentInfo = { ...@@ -248,8 +248,8 @@ let wantAgentInfo = {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
let basicContent = { let basicContent = {
title: "title", title: 'title',
text: "text" text: 'text'
}; };
let notificationContent = { let notificationContent = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -298,8 +298,8 @@ import wantAgent from '@ohos.app.ability.wantAgent'; ...@@ -298,8 +298,8 @@ import wantAgent from '@ohos.app.ability.wantAgent';
let wantAgentInfo = { let wantAgentInfo = {
wants: [ wants: [
{ {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility" abilityName: 'EntryAbility'
} }
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
...@@ -309,8 +309,8 @@ let wantAgentInfo = { ...@@ -309,8 +309,8 @@ let wantAgentInfo = {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
let basicContent = { let basicContent = {
title: "title", title: 'title',
text: "text" text: 'text'
}; };
let notificationContent = { let notificationContent = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -322,9 +322,9 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { ...@@ -322,9 +322,9 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
}; };
let id = 1; let id = 1;
particleAbility.startBackgroundRunning(id, request).then(() => { particleAbility.startBackgroundRunning(id, request).then(() => {
console.info("Operation succeeded"); console.info('Operation succeeded');
}).catch((err) => { }).catch((err) => {
console.error("Operation failed cause: " + JSON.stringify(err)); console.error('Operation failed cause: ${JSON.stringify(err)}');
}); });
}); });
...@@ -351,9 +351,9 @@ import particleAbility from '@ohos.ability.particleAbility'; ...@@ -351,9 +351,9 @@ import particleAbility from '@ohos.ability.particleAbility';
function callback(err, data) { function callback(err, data) {
if (err) { if (err) {
console.error("Operation failed cause: " + JSON.stringify(err)); console.error('Operation failed cause: ${JSON.stringify(err)}');
} else { } else {
console.info("Operation succeeded"); console.info('Operation succeeded');
} }
} }
...@@ -381,9 +381,9 @@ Requests to cancel a continuous task from the system. This API uses a promise to ...@@ -381,9 +381,9 @@ Requests to cancel a continuous task from the system. This API uses a promise to
import particleAbility from '@ohos.ability.particleAbility'; import particleAbility from '@ohos.ability.particleAbility';
particleAbility.cancelBackgroundRunning().then(() => { particleAbility.cancelBackgroundRunning().then(() => {
console.info("Operation succeeded"); console.info('Operation succeeded');
}).catch((err) => { }).catch((err) => {
console.error("Operation failed cause: " + JSON.stringify(err)); console.error('Operation failed cause: ${JSON.stringify(err)}');
}); });
``` ```
...@@ -413,25 +413,25 @@ Observe the following when using this API: ...@@ -413,25 +413,25 @@ Observe the following when using this API:
**Example** **Example**
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc' import rpc from '@ohos.rpc';
function onConnectCallback(element, remote) { function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); console.log('ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}');
} }
function onDisconnectCallback(element) { function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
} }
function onFailedCallback(code) { function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) console.log('particleAbilityTest ConnectAbility onFailed errCode : ${code}');
} }
var connId = particleAbility.connectAbility( let connId = particleAbility.connectAbility(
{ {
bundleName: "com.ix.ServiceAbility", bundleName: 'com.ix.ServiceAbility',
abilityName: "ServiceAbilityA", abilityName: 'ServiceAbilityA',
}, },
{ {
onConnect: onConnectCallback, onConnect: onConnectCallback,
...@@ -441,9 +441,9 @@ var connId = particleAbility.connectAbility( ...@@ -441,9 +441,9 @@ var connId = particleAbility.connectAbility(
); );
particleAbility.disconnectAbility(connId).then((data) => { particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data); console.log(' data: ${data}');
}).catch((error) => { }).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code) console.log('particleAbilityTest result errCode : ${error.code}');
}); });
``` ```
...@@ -468,21 +468,21 @@ import particleAbility from '@ohos.ability.particleAbility'; ...@@ -468,21 +468,21 @@ import particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
function onConnectCallback(element, remote) { function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); console.log('ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}');
} }
function onDisconnectCallback(element) { function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
} }
function onFailedCallback(code) { function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) console.log('particleAbilityTest ConnectAbility onFailed errCode : ${code}');
} }
var connId = particleAbility.connectAbility( let connId = particleAbility.connectAbility(
{ {
bundleName: "com.ix.ServiceAbility", bundleName: 'com.ix.ServiceAbility',
abilityName: "ServiceAbilityA", abilityName: 'ServiceAbilityA',
}, },
{ {
onConnect: onConnectCallback, onConnect: onConnectCallback,
...@@ -492,8 +492,7 @@ var connId = particleAbility.connectAbility( ...@@ -492,8 +492,7 @@ var connId = particleAbility.connectAbility(
); );
particleAbility.disconnectAbility(connId, (err) => { particleAbility.disconnectAbility(connId, (err) => {
console.log("particleAbilityTest disconnectAbility err====>" console.log('particleAbilityTest disconnectAbility err: ${JSON.stringify(err)}');
+ ("json err=") + JSON.stringify(err));
}); });
``` ```
...@@ -519,21 +518,21 @@ import particleAbility from '@ohos.ability.particleAbility'; ...@@ -519,21 +518,21 @@ import particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
function onConnectCallback(element, remote) { function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); console.log('ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}');
} }
function onDisconnectCallback(element) { function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
} }
function onFailedCallback(code) { function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) console.log('particleAbilityTest ConnectAbility onFailed errCode : ${code}');
} }
var connId = particleAbility.connectAbility( let connId = particleAbility.connectAbility(
{ {
bundleName: "com.ix.ServiceAbility", bundleName: 'com.ix.ServiceAbility',
abilityName: "ServiceAbilityA", abilityName: 'ServiceAbilityA',
}, },
{ {
onConnect: onConnectCallback, onConnect: onConnectCallback,
...@@ -543,9 +542,9 @@ var connId = particleAbility.connectAbility( ...@@ -543,9 +542,9 @@ var connId = particleAbility.connectAbility(
); );
particleAbility.disconnectAbility(connId).then((data) => { particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data); console.log(' data: ${data}');
}).catch((error) => { }).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code) console.log('particleAbilityTest result errCode : ${error.code}');
}); });
``` ```
......
...@@ -44,7 +44,7 @@ Enumerates the action constants of the **Want** object. **action** specifies the ...@@ -44,7 +44,7 @@ Enumerates the action constants of the **Want** object. **action** specifies the
| INTENT_PARAMS_INTENT | ability.want.params.INTENT | Action of displaying selection options with an action selector. | | INTENT_PARAMS_INTENT | ability.want.params.INTENT | Action of displaying selection options with an action selector. |
| INTENT_PARAMS_TITLE | ability.want.params.TITLE | Title of the character sequence dialog box used with the action selector. | | INTENT_PARAMS_TITLE | ability.want.params.TITLE | Title of the character sequence dialog box used with the action selector. |
| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | Action of selecting a file. | | ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | Action of selecting a file. |
| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | URI of the data stream associated with the target when the data is sent. | | PARAMS_STREAM<sup>7+</sup> | ability.params.stream | URI of the data stream associated with the target when the data is sent. The value must be an array of the string type. |
| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. | | ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. |
| ACTION_APP_ACCOUNT_AUTH <sup>9+</sup> | account.appAccount.action.auth | Action of providing the authentication service. | | ACTION_APP_ACCOUNT_AUTH <sup>9+</sup> | account.appAccount.action.auth | Action of providing the authentication service. |
| ACTION_MARKET_DOWNLOAD <sup>9+</sup> | ohos.want.action.marketDownload | Action of downloading an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. | | ACTION_MARKET_DOWNLOAD <sup>9+</sup> | ohos.want.action.marketDownload | Action of downloading an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
......
...@@ -28,7 +28,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; ...@@ -28,7 +28,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class MyUIAbility extends UIAbility { class MyUIAbility extends UIAbility {
onConfigurationUpdate(config) { onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, config:' + JSON.stringify(config)); console.log('onConfigurationUpdate, config: ${JSON.stringify(config)}');
} }
} }
``` ```
...@@ -55,7 +55,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; ...@@ -55,7 +55,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class MyUIAbility extends UIAbility { class MyUIAbility extends UIAbility {
onMemoryLevel(level) { onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level)); console.log('onMemoryLevel, level: ${JSON.stringify(level)}');
} }
} }
``` ```
...@@ -64,7 +64,7 @@ const config = { ...@@ -64,7 +64,7 @@ const config = {
language: 'Zh-Hans', // Simplified Chinese. language: 'Zh-Hans', // Simplified Chinese.
colorMode: COLOR_MODE_LIGHT, // Light theme. colorMode: COLOR_MODE_LIGHT, // Light theme.
direction: DIRECTION_VERTICAL, // Vertical direction. direction: DIRECTION_VERTICAL, // Vertical direction.
screenDensity: SCREEN_DENSITY_SDPI, // The screen resolution is SDPI. screenDensity: SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
displayId: 1, // The application is displayed on the display with ID 1. displayId: 1, // The application is displayed on the display with ID 1.
hasPointerDevice: true, // A pointer device is connected. hasPointerDevice: true, // A pointer device is connected.
}; };
...@@ -76,7 +76,7 @@ try { ...@@ -76,7 +76,7 @@ try {
} else { } else {
console.log('updateConfiguration success.'); console.log('updateConfiguration success.');
} }
}) });
} catch (paramError) { } catch (paramError) {
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
} }
...@@ -121,7 +121,7 @@ const config = { ...@@ -121,7 +121,7 @@ const config = {
language: 'Zh-Hans', // Simplified Chinese. language: 'Zh-Hans', // Simplified Chinese.
colorMode: COLOR_MODE_LIGHT, // Light theme. colorMode: COLOR_MODE_LIGHT, // Light theme.
direction: DIRECTION_VERTICAL, // Vertical direction. direction: DIRECTION_VERTICAL, // Vertical direction.
screenDensity: SCREEN_DENSITY_SDPI, // The screen resolution is SDPI. screenDensity: SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
displayId: 1, // The application is displayed on the display with ID 1. displayId: 1, // The application is displayed on the display with ID 1.
hasPointerDevice: true, // A pointer device is connected. hasPointerDevice: true, // A pointer device is connected.
}; };
...@@ -131,7 +131,7 @@ try { ...@@ -131,7 +131,7 @@ try {
console.log('updateConfiguration success.'); console.log('updateConfiguration success.');
}).catch((err) => { }).catch((err) => {
console.log('updateConfiguration fail, err: ${JSON.stringify(err)}'); console.log('updateConfiguration fail, err: ${JSON.stringify(err)}');
}) });
} catch (paramError) { } catch (paramError) {
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
} }
...@@ -306,7 +306,7 @@ try { ...@@ -306,7 +306,7 @@ try {
console.log('getExtensionRunningInfos success, data: ${JSON.stringify(data)}'); console.log('getExtensionRunningInfos success, data: ${JSON.stringify(data)}');
}).catch((err) => { }).catch((err) => {
console.log('getExtensionRunningInfos fail, err: ${JSON.stringify(err)}'); console.log('getExtensionRunningInfos fail, err: ${JSON.stringify(err)}');
}) });
} catch (paramError) { } catch (paramError) {
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
} }
...@@ -379,5 +379,5 @@ abilityManager.getTopAbility().then((data) => { ...@@ -379,5 +379,5 @@ abilityManager.getTopAbility().then((data) => {
console.log('getTopAbility success, data: ${JSON.stringify(data)}'); console.log('getTopAbility success, data: ${JSON.stringify(data)}');
}).catch((err) => { }).catch((err) => {
console.log('getTopAbility fail, err: ${JSON.stringify(err)}'); console.log('getTopAbility fail, err: ${JSON.stringify(err)}');
}) });
``` ```
...@@ -45,7 +45,7 @@ appManager.isRunningInStabilityTest((err, flag) => { ...@@ -45,7 +45,7 @@ appManager.isRunningInStabilityTest((err, flag) => {
} else { } else {
console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}'); console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}');
} }
}) });
``` ```
...@@ -151,7 +151,7 @@ appManager.isRamConstrainedDevice((err, data) => { ...@@ -151,7 +151,7 @@ appManager.isRamConstrainedDevice((err, data) => {
} else { } else {
console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}'); console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}');
} }
}) });
``` ```
## appManager.getAppMemorySize ## appManager.getAppMemorySize
...@@ -221,7 +221,7 @@ appManager.getAppMemorySize((err, data) => { ...@@ -221,7 +221,7 @@ appManager.getAppMemorySize((err, data) => {
} else { } else {
console.log('The size of app memory is: ${JSON.stringify(data)}'); console.log('The size of app memory is: ${JSON.stringify(data)}');
} }
}) });
``` ```
## appManager.getRunningProcessInformation ## appManager.getRunningProcessInformation
...@@ -295,7 +295,7 @@ appManager.getRunningProcessInformation((err, data) => { ...@@ -295,7 +295,7 @@ appManager.getRunningProcessInformation((err, data) => {
} else { } else {
console.log('The process running information is: ${JSON.stringify(data)}'); console.log('The process running information is: ${JSON.stringify(data)}');
} }
}) });
``` ```
## appManager.on ## appManager.on
...@@ -352,7 +352,7 @@ let applicationStateObserver = { ...@@ -352,7 +352,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) { onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`); console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
} }
} };
try { try {
const observerId = appManager.on('applicationState', applicationStateObserver); const observerId = appManager.on('applicationState', applicationStateObserver);
console.log(`[appManager] observerCode: ${observerId}`); console.log(`[appManager] observerCode: ${observerId}`);
...@@ -416,7 +416,7 @@ let applicationStateObserver = { ...@@ -416,7 +416,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) { onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`); console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
} }
} };
let bundleNameList = ['bundleName1', 'bundleName2']; let bundleNameList = ['bundleName1', 'bundleName2'];
try { try {
const observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList); const observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
...@@ -478,7 +478,7 @@ let applicationStateObserver = { ...@@ -478,7 +478,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) { onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`); console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
} }
} };
let bundleNameList = ['bundleName1', 'bundleName2']; let bundleNameList = ['bundleName1', 'bundleName2'];
try { try {
observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList); observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
...@@ -559,7 +559,7 @@ let applicationStateObserver = { ...@@ -559,7 +559,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) { onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`); console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
} }
} };
let bundleNameList = ['bundleName1', 'bundleName2']; let bundleNameList = ['bundleName1', 'bundleName2'];
try { try {
observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList); observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
...@@ -574,7 +574,7 @@ try { ...@@ -574,7 +574,7 @@ try {
console.log('unregisterApplicationStateObserver success, data: ${JSON.stringify(data)}'); console.log('unregisterApplicationStateObserver success, data: ${JSON.stringify(data)}');
}).catch((err) => { }).catch((err) => {
console.log('unregisterApplicationStateObserver fail, err: ${JSON.stringify(err)}'); console.log('unregisterApplicationStateObserver fail, err: ${JSON.stringify(err)}');
}) });
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.log('error: ${paramError.code}, ${paramError.message}');
} }
...@@ -660,7 +660,7 @@ appManager.getForegroundApplications().then((data) => { ...@@ -660,7 +660,7 @@ appManager.getForegroundApplications().then((data) => {
console.log('getForegroundApplications success, data: ${JSON.stringify(data)}'); console.log('getForegroundApplications success, data: ${JSON.stringify(data)}');
}).catch((err) => { }).catch((err) => {
console.log('getForegroundApplications fail, err: ${JSON.stringify(err)}'); console.log('getForegroundApplications fail, err: ${JSON.stringify(err)}');
}) });
``` ```
## appManager.killProcessWithAccount ## appManager.killProcessWithAccount
...@@ -702,7 +702,7 @@ try { ...@@ -702,7 +702,7 @@ try {
console.log('killProcessWithAccount success'); console.log('killProcessWithAccount success');
}).catch((err) => { }).catch((err) => {
console.error('killProcessWithAccount fail, err: ${JSON.stringify(err)}'); console.error('killProcessWithAccount fail, err: ${JSON.stringify(err)}');
}) });
} catch (paramError) { } catch (paramError) {
console.error('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
...@@ -844,7 +844,7 @@ try { ...@@ -844,7 +844,7 @@ try {
console.log('killProcessesByBundleName success.'); console.log('killProcessesByBundleName success.');
}).catch((err) => { }).catch((err) => {
console.log('killProcessesByBundleName fail, err: ${JSON.stringify(err)}'); console.log('killProcessesByBundleName fail, err: ${JSON.stringify(err)}');
}) });
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.log('error: ${paramError.code}, ${paramError.message}');
} }
...@@ -940,7 +940,7 @@ try { ...@@ -940,7 +940,7 @@ try {
console.log('clearUpApplicationData success.'); console.log('clearUpApplicationData success.');
}).catch((err) => { }).catch((err) => {
console.log('clearUpApplicationData fail, err: ${JSON.stringify(err)}'); console.log('clearUpApplicationData fail, err: ${JSON.stringify(err)}');
}) });
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.log('error: ${paramError.code}, ${paramError.message}');
} }
......
...@@ -10,7 +10,7 @@ The **Common** module provides all level-2 module APIs for developers to export. ...@@ -10,7 +10,7 @@ The **Common** module provides all level-2 module APIs for developers to export.
## Modules to Import ## Modules to Import
```ts ```ts
import common from '@ohos.app.ability.common' import common from '@ohos.app.ability.common';
``` ```
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
...@@ -24,16 +24,15 @@ import common from '@ohos.app.ability.common' ...@@ -24,16 +24,15 @@ import common from '@ohos.app.ability.common'
| Context | [Context](js-apis-inner-application-context.md) | Level-2 module **Context**.| | Context | [Context](js-apis-inner-application-context.md) | Level-2 module **Context**.|
| ExtensionContext | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Level-2 module **ExtensionContext**.| | ExtensionContext | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Level-2 module **ExtensionContext**.|
| FormExtensionContext | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Level-2 module **FormExtensionContext**.| | FormExtensionContext | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Level-2 module **FormExtensionContext**.|
| AreaMode | [AreaMode](#areamode) | Enumerated values of **AreaMode**.| | ServiceExtensionContext | [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md) | Level-2 module **ServiceExtensionContext**.|
| EventHub | [EventHub](js-apis-inner-application-eventHub.md) | Level-2 module **EventHub**.| | EventHub | [EventHub](js-apis-inner-application-eventHub.md) | Level-2 module **EventHub**.|
| PermissionRequestResult | [PermissionRequestResult](js-apis-inner-application-permissionRequestResult.md) | Level-2 module **PermissionRequestResult**.|
| PacMap | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#PacMap) | Level-2 module **PacMap**.| | PacMap | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#PacMap) | Level-2 module **PacMap**.|
| AbilityResult | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Level-2 module **AbilityResult**.| | AbilityResult | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Level-2 module **AbilityResult**.|
| ConnectOptions | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Level-2 module **ConnectOptions**.| | ConnectOptions | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Level-2 module **ConnectOptions**.|
**Example** **Example**
```ts ```ts
import common from '@ohos.app.ability.common' import common from '@ohos.app.ability.common';
let uiAbilityContext: common.UIAbilityContext; let uiAbilityContext: common.UIAbilityContext;
let abilityStageContext: common.AbilityStageContext; let abilityStageContext: common.AbilityStageContext;
...@@ -42,21 +41,8 @@ let baseContext: common.BaseContext; ...@@ -42,21 +41,8 @@ let baseContext: common.BaseContext;
let context: common.Context; let context: common.Context;
let extensionContext: common.ExtensionContext; let extensionContext: common.ExtensionContext;
let formExtensionContext: common.FormExtensionContext; let formExtensionContext: common.FormExtensionContext;
let areaMode: common.AreaMode;
let eventHub: common.EventHub; let eventHub: common.EventHub;
let permissionRequestResult: common.PermissionRequestResult;
let pacMap: common.PacMap; let pacMap: common.PacMap;
let abilityResult: common.AbilityResult; let abilityResult: common.AbilityResult;
let connectOptions: common.ConnectOptions; let connectOptions: common.ConnectOptions;
``` ```
## AreaMode
Enumerates the data encryption levels.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| --------------- | ---- | --------------- |
| EL1 | 0 | Device-level encryption area, which is accessible after the device is powered on. |
| EL2 | 1 | User-level encryption area, which is accessible only after the device is powered on and the password is entered (for the first time).|
# @ohos.app.ability.Configuration (Configuration) # @ohos.app.ability.Configuration (Configuration)
The **Configuration** module defines environment change information. The **Configuration** module defines environment change information. **Configuration** is an interface definition and is used only for field declaration.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```ts
import Configuration from '@ohos.app.ability.Configuration';
```
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| language | string | Yes| Yes| Language of the application, for example, **zh**.| | language | string | Yes| Yes| Language of the application, for example, **zh**.|
| colorMode | [ColorMode](js-apis-app-ability-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.| | colorMode | [ColorMode](js-apis-app-ability-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode. The default value is **COLOR_MODE_LIGHT**. The options are as follows:<br>- **COLOR_MODE_NOT_SET**: The color mode is not set.<br>- **COLOR_MODE_LIGHT**: light mode.<br>- **COLOR_MODE_DARK**: dark mode.|
| direction | [Direction](js-apis-app-ability-configurationConstant.md#configurationconstantdirection) | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.| | direction | [Direction](js-apis-app-ability-configurationConstant.md#configurationconstantdirection) | Yes| No| Screen orientation. The options are as follows:<br>- **DIRECTION_NOT_SET**: The screen orientation is not set.<br>- **DIRECTION_HORIZONTAL**: horizontal direction.<br>- **DIRECTION_VERTICAL**: vertical direction.|
| screenDensity | [ScreenDensity](js-apis-app-ability-configurationConstant.md#configurationconstantscreendensity) | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).| | screenDensity | [ScreenDensity](js-apis-app-ability-configurationConstant.md#configurationconstantscreendensity) | Yes| No| Pixel density of the screen. The options are as follows:<br>- **SCREEN_DENSITY_NOT_SET**: The pixel density is not set.<br>- **SCREEN_DENSITY_SDPI**: 120.<br>- **SCREEN_DENSITY_MDPI**: 160.<br>- **SCREEN_DENSITY_LDPI**: 240.<br>- **SCREEN_DENSITY_XLDPI**: 320.<br>- **SCREEN_DENSITY_XXLDPI**: 480.<br>- **SCREEN_DENSITY_XXXLDPI**: 640.|
| displayId | number | Yes| No| ID of the display where the application is located.| | displayId | number | Yes| No| ID of the display where the application is located.|
| hasPointerDevice | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.| | hasPointerDevice | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.|
...@@ -34,7 +28,7 @@ export default class EntryAbility extends UIAbility { ...@@ -34,7 +28,7 @@ export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) { onCreate(want, launchParam) {
let envCallback = { let envCallback = {
onConfigurationUpdated(config) { onConfigurationUpdated(config) {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`) console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`);
let language = config.language; let language = config.language;
let colorMode = config.colorMode; let colorMode = config.colorMode;
let direction = config.direction; let direction = config.direction;
...@@ -45,10 +39,10 @@ export default class EntryAbility extends UIAbility { ...@@ -45,10 +39,10 @@ export default class EntryAbility extends UIAbility {
}; };
try { try {
let applicationContext = this.context.getApplicationContext(); let applicationContext = this.context.getApplicationContext();
let callbackId = applicationContext.on("environment", envCallback); let callbackId = applicationContext.on('environment', envCallback);
console.log("callbackId: " + callbackId); console.log('callbackId: ${callbackId}');
} catch (paramError) { } catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message); console.log('error: ${paramError.code}, ${paramError.message}');
} }
} }
} }
......
...@@ -46,10 +46,10 @@ You can obtain the value of this constant by calling the **ConfigurationConstant ...@@ -46,10 +46,10 @@ You can obtain the value of this constant by calling the **ConfigurationConstant
| Name| Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.| | SCREEN_DENSITY_NOT_SET | 0 | The screen pixel density is not set.|
| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.| | SCREEN_DENSITY_SDPI | 120 | The pixel density of the screen is 'sdpi'.|
| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.| | SCREEN_DENSITY_MDPI | 160 | The pixel density of the screen is 'mdpi'.|
| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.| | SCREEN_DENSITY_LDPI | 240 | The pixel density of the screen is 'ldpi'.|
| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.| | SCREEN_DENSITY_XLDPI | 320 | The pixel density of the screen is 'xldpi'.|
| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.| | SCREEN_DENSITY_XXLDPI | 480 | The pixel density of the screen is 'xxldpi'.|
| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.| | SCREEN_DENSITY_XXXLDPI | 640 | The pixel density of the screen is 'xxxldpi'.|
...@@ -36,10 +36,10 @@ Obtains the ID attached to the end of a given URI. ...@@ -36,10 +36,10 @@ Obtains the ID attached to the end of a given URI.
```ts ```ts
try { try {
var 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}');
} }
``` ```
...@@ -69,15 +69,15 @@ Attaches an ID to the end of a given URI. ...@@ -69,15 +69,15 @@ Attaches an ID to the end of a given URI.
**Example** **Example**
```ts ```ts
var id = 1122; let id = 1122;
try { try {
var uri = dataUriUtils.attachId( let uri = dataUriUtils.attachId(
"com.example.dataUriUtils", 'com.example.dataUriUtils',
id, id,
) );
console.info('attachId the uri is: ' + uri) console.info('attachId the uri is: ${uri}');
} catch (err) { } catch (err) {
console.error('get id err ,check the uri' + err) console.error('get id err ,check the uri ${err}');
} }
``` ```
...@@ -108,10 +108,10 @@ Deletes the ID from the end of a given URI. ...@@ -108,10 +108,10 @@ Deletes the ID from the end of a given URI.
```ts ```ts
try { try {
var uri = dataUriUtils.deleteId("com.example.dataUriUtils/1221") let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221');
console.info('delete id with the uri is: ' + uri) console.info('delete id with the uri is: ${uri}');
} catch(err) { } catch(err) {
console.error('delete uri err, check the input uri' + err) console.error('delete uri err, check the input uri ${err}');
} }
``` ```
...@@ -144,12 +144,12 @@ Updates the ID in a given URI. ...@@ -144,12 +144,12 @@ Updates the ID in a given URI.
```ts ```ts
try { try {
var id = 1122; let id = 1122;
var uri = dataUriUtils.updateId( let uri = dataUriUtils.updateId(
"com.example.dataUriUtils/1221", 'com.example.dataUriUtils/1221',
id id
) );
} catch (err) { } catch (err) {
console.error('delete uri err, check the input uri' + err) console.error('delete uri err, check the input uri ${err}');
} }
``` ```
...@@ -11,7 +11,7 @@ The **EnvironmentCallback** module provides the **onConfigurationUpdated** API f ...@@ -11,7 +11,7 @@ The **EnvironmentCallback** module provides the **onConfigurationUpdated** API f
## Modules to Import ## Modules to Import
```ts ```ts
import EnvironmentCallback from "@ohos.app.ability.EnvironmentCallback"; import EnvironmentCallback from '@ohos.app.ability.EnvironmentCallback';
``` ```
...@@ -29,33 +29,51 @@ Called when the system environment changes. ...@@ -29,33 +29,51 @@ Called when the system environment changes.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-app-ability-configuration.md) | Yes| **Configuration** object after the change.| | config | [Configuration](js-apis-app-ability-configuration.md) | Yes| **Configuration** object after the change.|
## EnvironmentCallback.onMemoryLevel
onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system memory level changes.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| level | [AbilityConstant.MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.|
**Example** **Example**
```ts ```ts
import UIAbility from "@ohos.app.ability.Ability"; import UIAbility from '@ohos.app.ability.Ability';
var callbackId; let callbackId;
export default class MyAbility extends UIAbility { export default class MyAbility extends UIAbility {
onCreate() { onCreate() {
console.log("MyAbility onCreate") console.log('MyAbility onCreate');
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){
console.log('onMemoryLevel level: ${JSON.stringify(level)}');
} }
};
// 1. Obtain an applicationContext object. // 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext; let applicationContext = globalThis.applicationContext;
// 2. Register a listener for the environment changes through the applicationContext object. // 2. Register a listener for the environment changes through the applicationContext object.
callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback); callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId)); console.log('registerEnvironmentCallback number: ${JSON.stringify(callbackId)}');
} }
onDestroy() { onDestroy() {
let applicationContext = globalThis.applicationContext; let applicationContext = globalThis.applicationContext;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error)); console.log('unregisterEnvironmentCallback success, err: ${JSON.stringify(error)}');
}); });
} }
} }
......
...@@ -8,12 +8,12 @@ The **ErrorManager** module provides APIs for registering and deregistering erro ...@@ -8,12 +8,12 @@ The **ErrorManager** module provides APIs for registering and deregistering erro
## Modules to Import ## Modules to Import
```ts ```ts
import errorManager from '@ohos.app.ability.errorManager' import errorManager from '@ohos.app.ability.errorManager';
``` ```
## ErrorManager.on ## ErrorManager.on
on(type: "error", observer: ErrorObserver): number; on(type: 'error', observer: ErrorObserver): number;
Registers an error observer. Registers an error observer.
...@@ -35,22 +35,22 @@ Registers an error observer. ...@@ -35,22 +35,22 @@ Registers an error observer.
**Example** **Example**
```ts ```ts
var observer = { let observer = {
onUnhandledException(errorMsg) { onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg) console.log('onUnhandledException, errorMsg: ', errorMsg);
} }
} };
var observerId = -1; let observerId = -1;
try { try {
observerId = errorManager.on("error", observer); observerId = errorManager.on('error', observer);
} catch (paramError) { } catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message); console.log('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
## ErrorManager.off ## ErrorManager.off
off(type: "error", observerId: number, callback: AsyncCallback\<void>): void; off(type: 'error', observerId: number, callback: AsyncCallback\<void>): void;
Deregisters an error observer. This API uses an asynchronous callback to return the result. Deregisters an error observer. This API uses an asynchronous callback to return the result.
...@@ -67,7 +67,7 @@ Deregisters an error observer. This API uses an asynchronous callback to return ...@@ -67,7 +67,7 @@ Deregisters an error observer. This API uses an asynchronous callback to return
**Example** **Example**
```ts ```ts
var observerId = 100; let observerId = 100;
function unregisterErrorObserverCallback(err) { function unregisterErrorObserverCallback(err) {
if (err) { if (err) {
...@@ -75,15 +75,15 @@ function unregisterErrorObserverCallback(err) { ...@@ -75,15 +75,15 @@ function unregisterErrorObserverCallback(err) {
} }
} }
try { try {
errorManager.off("error", observerId, unregisterErrorObserverCallback); errorManager.off('error', observerId, unregisterErrorObserverCallback);
} catch (paramError) { } catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message); console.log('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
## ErrorManager.off ## ErrorManager.off
off(type: "error", observerId: number): Promise\<void>; off(type: 'error', observerId: number): Promise\<void>;
Deregisters an error observer. This API uses a promise to return the result. Deregisters an error observer. This API uses a promise to return the result.
...@@ -105,17 +105,17 @@ Deregisters an error observer. This API uses a promise to return the result. ...@@ -105,17 +105,17 @@ Deregisters an error observer. This API uses a promise to return the result.
**Example** **Example**
```ts ```ts
var observerId = 100; let observerId = 100;
try { try {
errorManager.off("error", observerId) errorManager.off('error', observerId)
.then((data) => { .then((data) => {
console.log('----------- unregisterErrorObserver success ----------', data); console.log('----------- unregisterErrorObserver success ----------', data);
}) })
.catch((err) => { .catch((err) => {
console.log('----------- unregisterErrorObserver fail ----------', err); console.log('----------- unregisterErrorObserver fail ----------', err);
}) });
} catch (paramError) { } catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message); console.log('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -24,7 +24,7 @@ Defines the quick fix information at the HAP file level. ...@@ -24,7 +24,7 @@ Defines the quick fix information at the HAP file level.
| ----------- | -------------------- | ---- | ------------------------------------------------------------ | | ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| moduleName | string | Yes | Name of the HAP file. | | moduleName | string | Yes | Name of the HAP file. |
| originHapHash | string | Yes | Hash value of the HAP file. | | originHapHash | string | Yes | Hash value of the HAP file. |
| quickFixFilePath | string | Yes | Installation path of the quick fix file. | | quickFixFilePath | string | Yes | Installation path of the quick fix patch file. |
## ApplicationQuickFixInfo ## ApplicationQuickFixInfo
...@@ -57,25 +57,29 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the ...@@ -57,25 +57,29 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the
**Parameters** **Parameters**
| Parameter| Type| Mandatory| Description| | Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix files, each of which must contain a valid file path.| | hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
> **NOTE**
>
> The file path passed in the API must be an application sandbox path. For details about how to obtain the sandbox path, see [Obtaining the Sandbox Path](js-apis-bundle-BundleInstaller.md#obtaining-the-sandbox-path). The path mapped to the device is **/proc/<*applicationProcessId*>/root/*sandboxPath***.
**Example** **Example**
```ts ```ts
try { try {
let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"] let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf'];
quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => { quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => {
if (error) { if (error) {
console.info( `applyQuickFix failed with error + ${error}`) console.info( `applyQuickFix failed with error: ${error}`);
} else { } else {
console.info( 'applyQuickFix success') console.info( 'applyQuickFix success');
} }
}) });
} catch (paramError) { } catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message); console.log('error.code: ${paramError.code}, error.message: ${paramError.message}');
} }
``` ```
...@@ -93,28 +97,28 @@ Applies a quick fix patch. This API uses a promise to return the result. ...@@ -93,28 +97,28 @@ Applies a quick fix patch. This API uses a promise to return the result.
**Parameters** **Parameters**
| Parameter| Type| Mandatory| Description| | Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix files, each of which must contain a valid file path.| | hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Example** **Example**
```ts ```ts
let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"] let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf'];
try { try {
quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => { quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => {
console.info('applyQuickFix success') console.info('applyQuickFix success');
}).catch((error) => { }).catch((error) => {
console.info(`applyQuickFix err: + ${error}`) console.info(`applyQuickFix err: ${error}`);
}) });
} catch (paramError) { } catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message); console.log('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -141,16 +145,16 @@ Obtains the quick fix information of the application. This API uses an asynchron ...@@ -141,16 +145,16 @@ Obtains the quick fix information of the application. This API uses an asynchron
```ts ```ts
try { try {
let bundleName = "bundleName" let bundleName = 'bundleName';
quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => { quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => {
if (error) { if (error) {
console.info(`getApplicationQuickFixInfo error: + ${error}`) console.info(`getApplicationQuickFixInfo error: ${error}`);
} else { } else {
console.info(`getApplicationQuickFixInfo success: + ${data}`) console.info(`getApplicationQuickFixInfo success: ${data}`);
} }
}) });
} catch (paramError) { } catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message); console.log('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -174,21 +178,21 @@ Obtains the quick fix information of the application. This API uses a promise to ...@@ -174,21 +178,21 @@ Obtains the quick fix information of the application. This API uses a promise to
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.| | Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
**Example** **Example**
```ts ```ts
try { try {
let bundleName = "bundleName" let bundleName = 'bundleName';
quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => { quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => {
console.info(`getApplicationQuickFixInfo success: + ${data}`) console.info(`getApplicationQuickFixInfo success: ${data}`);
}).catch((error) => { }).catch((error) => {
console.info(`getApplicationQuickFixInfo err: + ${error}`) console.info(`getApplicationQuickFixInfo err: ${error}`);
}) });
} catch (paramError) { } catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message); console.log('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -49,7 +49,7 @@ Called when a ServiceExtensionAbility is created to initialize the service logic ...@@ -49,7 +49,7 @@ Called when a ServiceExtensionAbility is created to initialize the service logic
```ts ```ts
class ServiceExt extends ServiceExtension { class ServiceExt extends ServiceExtension {
onCreate(want) { onCreate(want) {
console.log('onCreate, want:' + want.abilityName); console.log('onCreate, want: ${want.abilityName}');
} }
} }
``` ```
...@@ -80,7 +80,7 @@ Called when this ServiceExtensionAbility is destroyed to clear resources. ...@@ -80,7 +80,7 @@ Called when this ServiceExtensionAbility is destroyed to clear resources.
onRequest(want: Want, startId: number): void; onRequest(want: Want, startId: number): void;
Called following **onCreate()** when a ServiceExtensionAbility is started by calling **startAbility()**. The value of **startId** is incremented for each ability that is started. Called following **onCreate()** when a ServiceExtensionAbility is started by calling **startAbility()** or **startServiceExtensionAbility()**. The value of **startId** is incremented for each ability that is started.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -98,7 +98,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal ...@@ -98,7 +98,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
```ts ```ts
class ServiceExt extends ServiceExtension { class ServiceExt extends ServiceExtension {
onRequest(want, startId) { onRequest(want, startId) {
console.log('onRequest, want:' + want.abilityName); console.log('onRequest, want: ${want.abilityName}');
} }
} }
``` ```
...@@ -129,7 +129,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal ...@@ -129,7 +129,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
**Example** **Example**
```ts ```ts
import rpc from '@ohos.rpc' import rpc from '@ohos.rpc';
class StubTest extends rpc.RemoteObject{ class StubTest extends rpc.RemoteObject{
constructor(des) { constructor(des) {
super(des); super(des);
...@@ -139,8 +139,8 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal ...@@ -139,8 +139,8 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
} }
class ServiceExt extends ServiceExtension { class ServiceExt extends ServiceExtension {
onConnect(want) { onConnect(want) {
console.log('onConnect , want:' + want.abilityName); console.log('onConnect , want: ${want.abilityName}');
return new StubTest("test"); return new StubTest('test');
} }
} }
``` ```
...@@ -167,7 +167,7 @@ Called when a client is disconnected from this ServiceExtensionAbility. ...@@ -167,7 +167,7 @@ Called when a client is disconnected from this ServiceExtensionAbility.
```ts ```ts
class ServiceExt extends ServiceExtension { class ServiceExt extends ServiceExtension {
onDisconnect(want) { onDisconnect(want) {
console.log('onDisconnect, want:' + want.abilityName); console.log('onDisconnect, want: ${want.abilityName}');
} }
} }
``` ```
...@@ -193,7 +193,7 @@ Called when a new client attempts to connect to this ServiceExtensionAbility aft ...@@ -193,7 +193,7 @@ Called when a new client attempts to connect to this ServiceExtensionAbility aft
```ts ```ts
class ServiceExt extends ServiceExtension { class ServiceExt extends ServiceExtension {
onReconnect(want) { onReconnect(want) {
console.log('onReconnect, want:' + want.abilityName); console.log('onReconnect, want: ${want.abilityName}');
} }
} }
``` ```
...@@ -219,7 +219,7 @@ Called when the configuration of this ServiceExtensionAbility is updated. ...@@ -219,7 +219,7 @@ Called when the configuration of this ServiceExtensionAbility is updated.
```ts ```ts
class ServiceExt extends ServiceExtension { class ServiceExt extends ServiceExtension {
onConfigurationUpdate(config) { onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, config:' + JSON.stringify(config)); console.log('onConfigurationUpdate, config: ${JSON.stringify(config)}');
} }
} }
``` ```
...@@ -245,8 +245,8 @@ Dumps the client information. ...@@ -245,8 +245,8 @@ Dumps the client information.
```ts ```ts
class ServiceExt extends ServiceExtension { class ServiceExt extends ServiceExtension {
onDump(params) { onDump(params) {
console.log('dump, params:' + JSON.stringify(params)); console.log('dump, params: ${JSON.stringify(params)}');
return ["params"] return ['params'];
} }
} }
``` ```
...@@ -47,7 +47,7 @@ Called to initialize the service logic when a UIAbility is created. ...@@ -47,7 +47,7 @@ Called to initialize the service logic when a UIAbility is created.
```ts ```ts
class MyUIAbility extends UIAbility { class MyUIAbility extends UIAbility {
onCreate(want, param) { onCreate(want, param) {
console.log('onCreate, want:' + want.abilityName); console.log('onCreate, want: ${want.abilityName}');
} }
} }
``` ```
...@@ -202,11 +202,11 @@ Called to save data during the ability migration preparation process. ...@@ -202,11 +202,11 @@ Called to save data during the ability migration preparation process.
**Example** **Example**
```ts ```ts
import AbilityConstant from "@ohos.app.ability.AbilityConstant" import AbilityConstant from '@ohos.app.ability.AbilityConstant';
class MyUIAbility extends UIAbility { class MyUIAbility extends UIAbility {
onContinue(wantParams) { onContinue(wantParams) {
console.log('onContinue'); console.log('onContinue');
wantParams["myData"] = "my1234567"; wantParams['myData'] = 'my1234567';
return AbilityConstant.OnContinueResult.AGREE; return AbilityConstant.OnContinueResult.AGREE;
} }
} }
...@@ -233,8 +233,8 @@ Called when a new Want is passed in and this UIAbility is started again. ...@@ -233,8 +233,8 @@ Called when a new Want is passed in and this UIAbility is started again.
```ts ```ts
class MyUIAbility extends UIAbility { class MyUIAbility extends UIAbility {
onNewWant(want, launchParams) { onNewWant(want, launchParams) {
console.log('onNewWant, want:' + want.abilityName); console.log('onNewWant, want: ${want.abilityName}');
console.log('onNewWant, launchParams:' + JSON.stringify(launchParams)); console.log('onNewWant, launchParams: ${JSON.stringify(launchParams)}');
} }
} }
``` ```
...@@ -258,8 +258,8 @@ Dumps client information. ...@@ -258,8 +258,8 @@ Dumps client information.
```ts ```ts
class MyUIAbility extends UIAbility { class MyUIAbility extends UIAbility {
onDump(params) { onDump(params) {
console.log('dump, params:' + JSON.stringify(params)); console.log('dump, params: ${JSON.stringify(params)}');
return ["params"] return ['params'];
} }
} }
``` ```
...@@ -289,12 +289,12 @@ Called when the framework automatically saves the UIAbility state in the case of ...@@ -289,12 +289,12 @@ Called when the framework automatically saves the UIAbility state in the case of
**Example** **Example**
```ts ```ts
import AbilityConstant from '@ohos.app.ability.AbilityConstant' import AbilityConstant from '@ohos.app.ability.AbilityConstant';
class MyUIAbility extends UIAbility { class MyUIAbility extends UIAbility {
onSaveState(reason, wantParam) { onSaveState(reason, wantParam) {
console.log('onSaveState'); console.log('onSaveState');
wantParam["myData"] = "my1234567"; wantParam['myData'] = 'my1234567';
return AbilityConstant.OnSaveResult.RECOVERY_AGREE; return AbilityConstant.OnSaveResult.RECOVERY_AGREE;
} }
} }
...@@ -339,8 +339,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -339,8 +339,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts ```ts
class MyMessageAble{ // Custom sequenceable data structure. class MyMessageAble{ // Custom sequenceable data structure.
name:"" name:''
str:"" str:''
num: 1 num: 1
constructor(name, str) { constructor(name, str) {
this.name = name; this.name = name;
...@@ -349,38 +349,36 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -349,38 +349,36 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
marshalling(messageParcel) { marshalling(messageParcel) {
messageParcel.writeInt(this.num); messageParcel.writeInt(this.num);
messageParcel.writeString(this.str); messageParcel.writeString(this.str);
console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble marshalling num[${this.num}] str[${this.str}]');
return true; return true;
} }
unmarshalling(messageParcel) { unmarshalling(messageParcel) {
this.num = messageParcel.readInt(); this.num = messageParcel.readInt();
this.str = messageParcel.readString(); this.str = messageParcel.readString();
console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble unmarshalling num[${this.num}] str[${this.str}]');
return true; return true;
} }
}; };
var method = 'call_Function'; // Notification message string negotiated by the two abilities. let method = 'call_Function'; // Notification message string negotiated by the two abilities.
var caller; let caller;
export default class MainUIAbility extends UIAbility { export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
this.context.startUIAbilityByCall({ this.context.startAbilityByCall({
bundleName: "com.example.myservice", bundleName: 'com.example.myservice',
abilityName: "MainUIAbility", abilityName: 'MainUIAbility',
deviceId: "" deviceId: ''
}).then((obj) => { }).then((obj) => {
caller = obj; caller = obj;
let msg = new MyMessageAble("msg", "world"); // See the definition of Sequenceable. let msg = new MyMessageAble('msg', 'world'); // See the definition of Sequenceable.
caller.call(method, msg) caller.call(method, msg)
.then(() => { .then(() => {
console.log('Caller call() called'); console.log('Caller call() called');
}) })
.catch((callErr) => { .catch((callErr) => {
console.log('Caller.call catch error, error.code: ' + JSON.stringify(callErr.code) + console.log('Caller.call catch error, error.code: ${JSON.stringify(callErr.code)}, error.message: ${JSON.stringify(callErr.message)}');
' error.message: ' + JSON.stringify(callErr.message));
}); });
}).catch((err) => { }).catch((err) => {
console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) + console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
' error.message: ' + JSON.stringify(err.message));
}); });
} }
} }
...@@ -420,8 +418,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -420,8 +418,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts ```ts
class MyMessageAble{ class MyMessageAble{
name:"" name:''
str:"" str:''
num: 1 num: 1
constructor(name, str) { constructor(name, str) {
this.name = name; this.name = name;
...@@ -430,40 +428,38 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -430,40 +428,38 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
marshalling(messageParcel) { marshalling(messageParcel) {
messageParcel.writeInt(this.num); messageParcel.writeInt(this.num);
messageParcel.writeString(this.str); messageParcel.writeString(this.str);
console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble marshalling num[${this.num}] str[${this.str}]');
return true; return true;
} }
unmarshalling(messageParcel) { unmarshalling(messageParcel) {
this.num = messageParcel.readInt(); this.num = messageParcel.readInt();
this.str = messageParcel.readString(); this.str = messageParcel.readString();
console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble unmarshalling num[${this.num] str[${this.str}]');
return true; return true;
} }
}; };
var method = 'call_Function'; let method = 'call_Function';
var caller; let caller;
export default class MainUIAbility extends UIAbility { export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
this.context.startUIAbilityByCall({ this.context.startAbilityByCall({
bundleName: "com.example.myservice", bundleName: 'com.example.myservice',
abilityName: "MainUIAbility", abilityName: 'MainUIAbility',
deviceId: "" deviceId: ''
}).then((obj) => { }).then((obj) => {
caller = obj; caller = obj;
let msg = new MyMessageAble(1, "world"); let msg = new MyMessageAble(1, 'world');
caller.callWithResult(method, msg) caller.callWithResult(method, msg)
.then((data) => { .then((data) => {
console.log('Caller callWithResult() called'); console.log('Caller callWithResult() called');
let retmsg = new MyMessageAble(0, ""); let retmsg = new MyMessageAble(0, '');
data.readSequenceable(retmsg); data.readSequenceable(retmsg);
}) })
.catch((callErr) => { .catch((callErr) => {
console.log('Caller.callWithResult catch error, error.code: ' + JSON.stringify(callErr.code) + console.log('Caller.callWithResult catch error, error.code: ${JSON.stringify(callErr.code)}, error.message: ${JSON.stringify(callErr.message)}');
' error.message: ' + JSON.stringify(callErr.message));
}); });
}).catch((err) => { }).catch((err) => {
console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) + console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
' error.message: ' + JSON.stringify(err.message));
}); });
} }
} }
...@@ -490,24 +486,22 @@ Releases the caller interface of the target ability. ...@@ -490,24 +486,22 @@ Releases the caller interface of the target ability.
**Example** **Example**
```ts ```ts
var caller; let caller;
export default class MainUIAbility extends UIAbility { export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
this.context.startUIAbilityByCall({ this.context.startAbilityByCall({
bundleName: "com.example.myservice", bundleName: 'com.example.myservice',
abilityName: "MainUIAbility", abilityName: 'MainUIAbility',
deviceId: "" deviceId: ''
}).then((obj) => { }).then((obj) => {
caller = obj; caller = obj;
try { try {
caller.release(); caller.release();
} catch (releaseErr) { } catch (releaseErr) {
console.log('Caller.release catch error, error.code: ' + JSON.stringify(releaseErr.code) + console.log('Caller.release catch error, error.code: ${JSON.stringify(releaseErr.code)}, error.message: ${JSON.stringify(releaseErr.message)}');
' error.message: ' + JSON.stringify(releaseErr.message));
} }
}).catch((err) => { }).catch((err) => {
console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) + console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
' error.message: ' + JSON.stringify(err.message));
}); });
} }
} }
...@@ -525,31 +519,29 @@ Registers a callback that is invoked when the stub on the target ability is disc ...@@ -525,31 +519,29 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used for the **onRelease** API.| | callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
**Example** **Example**
```ts ```ts
var caller; let caller;
export default class MainUIAbility extends UIAbility { export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
this.context.startUIAbilityByCall({ this.context.startAbilityByCall({
bundleName: "com.example.myservice", bundleName: 'com.example.myservice',
abilityName: "MainUIAbility", abilityName: 'MainUIAbility',
deviceId: "" deviceId: ''
}).then((obj) => { }).then((obj) => {
caller = obj; caller = obj;
try { try {
caller.onRelease((str) => { caller.onRelease((str) => {
console.log(' Caller OnRelease CallBack is called ' + str); console.log(' Caller OnRelease CallBack is called ${str}');
}); });
} catch (error) { } catch (error) {
console.log('Caller.on catch error, error.code: ' + JSON.stringify(error.code) + console.log('Caller.onRelease catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
' error.message: ' + JSON.stringify(error.message));
} }
}).catch((err) => { }).catch((err) => {
console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) + console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
' error.message: ' + JSON.stringify(err.message));
}); });
} }
} }
...@@ -557,7 +549,7 @@ Registers a callback that is invoked when the stub on the target ability is disc ...@@ -557,7 +549,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
## Caller.on ## Caller.on
on(type: "release", callback: OnReleaseCallback): void; on(type: 'release', callback: OnReleaseCallback): void;
Registers a callback that is invoked when the stub on the target ability is disconnected. Registers a callback that is invoked when the stub on the target ability is disconnected.
...@@ -568,7 +560,7 @@ Registers a callback that is invoked when the stub on the target ability is disc ...@@ -568,7 +560,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.| | type | string | Yes| Event type. The value is fixed at **release**.|
| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used for the **onRelease** API.| | callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
**Error codes** **Error codes**
...@@ -581,31 +573,127 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -581,31 +573,127 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example** **Example**
```ts ```ts
var caller; let caller;
export default class MainUIAbility extends UIAbility { export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
this.context.startUIAbilityByCall({ this.context.startAbilityByCall({
bundleName: "com.example.myservice", bundleName: 'com.example.myservice',
abilityName: "MainUIAbility", abilityName: 'MainUIAbility',
deviceId: "" deviceId: ''
}).then((obj) => { }).then((obj) => {
caller = obj; caller = obj;
try { try {
caller.on("release", (str) => { caller.on('release', (str) => {
console.log(' Caller OnRelease CallBack is called ' + str); console.log(' Caller OnRelease CallBack is called ${str}');
}); });
} catch (error) { } catch (error) {
console.log('Caller.on catch error, error.code: ' + JSON.stringify(error.code) + console.log('Caller.on catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
' error.message: ' + JSON.stringify(error.message));
} }
}).catch((err) => { }).catch((err) => {
console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) + console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
' error.message: ' + JSON.stringify(err.message));
}); });
} }
} }
``` ```
## Caller.off
off(type: 'release', callback: OnReleaseCallback): void;
Deregisters a callback that is invoked when the stub on the target ability is disconnected. This capability is reserved.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.|
| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
let caller;
export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: 'com.example.myservice',
abilityName: 'MainUIAbility',
deviceId: ''
}).then((obj) => {
caller = obj;
try {
let onReleaseCallBack = (str) => {
console.log(' Caller OnRelease CallBack is called ${str}');
};
caller.on('release', onReleaseCallBack);
caller.off('release', onReleaseCallBack);
} catch (error) {
console.log('Caller.on or Caller.off catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
}).catch((err) => {
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
});
}
}
```
## Caller.off
off(type: 'release'): void;
Deregisters a callback that is invoked when the stub on the target ability is disconnected. This capability is reserved.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
let caller;
export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: 'com.example.myservice',
abilityName: 'MainUIAbility',
deviceId: ''
}).then((obj) => {
caller = obj;
try {
let onReleaseCallBack = (str) => {
console.log(' Caller OnRelease CallBack is called ${str}');
};
caller.on('release', onReleaseCallBack);
caller.off('release');
} catch (error) {
console.error('Caller.on or Caller.off catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
}).catch((err) => {
console.error('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
});
}
}
```
## Callee ## Callee
...@@ -638,8 +726,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -638,8 +726,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts ```ts
class MyMessageAble{ class MyMessageAble{
name:"" name:''
str:"" str:''
num: 1 num: 1
constructor(name, str) { constructor(name, str) {
this.name = name; this.name = name;
...@@ -648,22 +736,22 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -648,22 +736,22 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
marshalling(messageParcel) { marshalling(messageParcel) {
messageParcel.writeInt(this.num); messageParcel.writeInt(this.num);
messageParcel.writeString(this.str); messageParcel.writeString(this.str);
console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble marshalling num[${this.num}] str[${this.str}]');
return true; return true;
} }
unmarshalling(messageParcel) { unmarshalling(messageParcel) {
this.num = messageParcel.readInt(); this.num = messageParcel.readInt();
this.str = messageParcel.readString(); this.str = messageParcel.readString();
console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble unmarshalling num[${this.num}] str[${this.str}]');
return true; return true;
} }
}; };
var method = 'call_Function'; let method = 'call_Function';
function funcCallBack(pdata) { function funcCallBack(pdata) {
console.log('Callee funcCallBack is called ' + pdata); console.log('Callee funcCallBack is called ${pdata}');
let msg = new MyMessageAble("test", ""); let msg = new MyMessageAble('test', '');
pdata.readSequenceable(msg); pdata.readSequenceable(msg);
return new MyMessageAble("test1", "Callee test"); return new MyMessageAble('test1', 'Callee test');
} }
export default class MainUIAbility extends UIAbility { export default class MainUIAbility extends UIAbility {
onCreate(want, launchParam) { onCreate(want, launchParam) {
...@@ -671,8 +759,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -671,8 +759,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
try { try {
this.callee.on(method, funcCallBack); this.callee.on(method, funcCallBack);
} catch (error) { } catch (error) {
console.log('Callee.on catch error, error.code: ' + JSON.stringify(error.code) + console.log('Callee.on catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
' error.message: ' + JSON.stringify(error.message));
} }
} }
} }
...@@ -704,15 +791,14 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -704,15 +791,14 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example** **Example**
```ts ```ts
var method = 'call_Function'; let method = 'call_Function';
export default class MainUIAbility extends UIAbility { export default class MainUIAbility extends UIAbility {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log('Callee onCreate is called'); console.log('Callee onCreate is called');
try { try {
this.callee.off(method); this.callee.off(method);
} catch (error) { } catch (error) {
console.log('Callee.off catch error, error.code: ' + JSON.stringify(error.code) + console.log('Callee.off catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
' error.message: ' + JSON.stringify(error.message));
} }
} }
} }
......
...@@ -22,115 +22,133 @@ import Want from '@ohos.app.ability.Want'; ...@@ -22,115 +22,133 @@ import Want from '@ohos.app.ability.Want';
| bundleName | string | No | Bundle name of the ability.| | bundleName | string | No | Bundle name of the ability.|
| moduleName | string | No| Name of the module to which the ability belongs.| | moduleName | string | No| Name of the module to which the ability belongs.|
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.| | abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| [action](js-apis-app-ability-wantConstant.md#wantconstantaction) | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](../../application-models/explicit-implicit-want-mappings.md). | | action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](../../application-models/explicit-implicit-want-mappings.md). |
| [entities](js-apis-app-ability-wantConstant.md#wantconstantentity) | Array\<string> | No| Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types.| | entities | Array\<string> | No| Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types.|
| uri | string | No| Data carried. This field is used together with **type** to specify the data type. If **uri** is specified in a Want, the Want will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| | uri | string | No| Data carried. This field is used together with **type** to specify the data type. If **uri** is specified in a Want, the Want will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | string | No| MIME type, that is, the type of the file to open, for example, **text/xml** and **image/***. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com.| | type | string | No| MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com.|
| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>- **ohos.aafwk.callerPid**: PID of the caller.<br>- **ohos.aafwk.param.callerToken**: token of the caller.<br>- **ohos.aafwk.param.callerUid**: UID in [BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information. | | parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>- **ohos.aafwk.callerPid**: PID of the caller.<br>- **ohos.aafwk.param.callerToken**: token of the caller.<br>- **ohos.aafwk.param.callerUid**: UID in [BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files. |
| [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | No| How the **Want** object will be handled. By default, a number is passed in.<br>For example, **wantConstant.Flags.FLAG_ABILITY_CONTINUATION** specifies whether to start the ability in cross-device migration scenarios.| | [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | No| How the **Want** object will be handled. By default, a number is passed in.<br>For example, **wantConstant.Flags.FLAG_ABILITY_CONTINUATION** specifies whether to start the ability in cross-device migration scenarios.|
**Example** **Example**
- Basic usage (called in a UIAbility object, where context in the example is the context object of the UIAbility). - Basic usage: called in a UIAbility object, as shown in the example below. For details about how to obtain the context, see [Obtaining the Context of UIAbility](../../application-models/uiability-usage.md#obtaining-the-context-of-uiability).
```ts ```ts
let want = { let want = {
"deviceId": "", // An empty deviceId indicates the local device. 'deviceId': '', // An empty deviceId indicates the local device.
"bundleName": "com.example.myapplication", 'bundleName': 'com.example.myapplication',
"abilityName": "FuncAbility", 'abilityName': 'FuncAbility',
"moduleName": "entry" // moduleName is optional. 'moduleName': 'entry' // moduleName is optional.
}; };
this.context.startAbility(want, (error) => {
this.context.startAbility(want, (err) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability. // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log("error.code = " + error.code) console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
}) });
``` ```
- Data is transferred through user-defined fields. The following data types are supported (called in a UIAbility object, where context in the example is the context object of the UIAbility): - Data is transferred through user-defined fields. The following data types are supported (called in a UIAbility object, as shown in the example below. For details about how to obtain the context, see [Obtaining the Context of UIAbility](../../application-models/uiability-usage.md#obtaining-the-context-of-uiability).)
* String * String
```ts ```ts
let want = { let want = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "FuncAbility", abilityName: 'FuncAbility',
parameters: { parameters: {
keyForString: "str", keyForString: 'str',
}, },
} };
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
``` ```
* Number * Number
```ts ```ts
let want = { let want = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "FuncAbility", abilityName: 'FuncAbility',
parameters: { parameters: {
keyForInt: 100, keyForInt: 100,
keyForDouble: 99.99, keyForDouble: 99.99,
}, },
} };
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
``` ```
* Boolean * Boolean
```ts ```ts
let want = { let want = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "FuncAbility", abilityName: 'FuncAbility',
parameters: { parameters: {
keyForBool: true, keyForBool: true,
}, },
} };
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
``` ```
* Object * Object
```ts ```ts
let want = { let want = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "FuncAbility", abilityName: 'FuncAbility',
parameters: { parameters: {
keyForObject: { keyForObject: {
keyForObjectString: "str", keyForObjectString: 'str',
keyForObjectInt: -200, keyForObjectInt: -200,
keyForObjectDouble: 35.5, keyForObjectDouble: 35.5,
keyForObjectBool: false, keyForObjectBool: false,
}, },
}, },
} };
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
``` ```
* Array * Array
```ts ```ts
let want = { let want = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "FuncAbility", abilityName: 'FuncAbility',
parameters: { parameters: {
keyForArrayString: ["str1", "str2", "str3"], keyForArrayString: ['str1', 'str2', 'str3'],
keyForArrayInt: [100, 200, 300, 400], keyForArrayInt: [100, 200, 300, 400],
keyForArrayDouble: [0.1, 0.2], keyForArrayDouble: [0.1, 0.2],
keyForArrayObject: [{obj1: "aaa"}, {obj2: 100}], keyForArrayObject: [{ obj1: 'aaa' }, { obj2: 100 }],
}, },
} };
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
``` ```
* File descriptor (FD) * File descriptor (FD)
```ts ```ts
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
let fd; let fd;
try { try {
fd = fileio.openSync("/data/storage/el2/base/haps/pic.png"); fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
} catch(e) { } catch(e) {
console.log("openSync fail:" + JSON.stringify(e)); console.log('openSync fail: ${JSON.stringify(e)}');
} }
let want = { let want = {
"deviceId": "", // An empty deviceId indicates the local device. 'deviceId': '', // An empty deviceId indicates the local device.
"bundleName": "com.example.myapplication", 'bundleName': 'com.example.myapplication',
"abilityName": "FuncAbility", 'abilityName': 'FuncAbility',
"moduleName": "entry", // moduleName is optional. 'moduleName': 'entry', // moduleName is optional.
"parameters": { 'parameters': {
"keyFd":{"type":"FD", "value":fd} 'keyFd': { 'type': 'FD', 'value': fd } // {'type':'FD', 'value':fd} is a fixed usage, indicating that the data is a file descriptor.
} }
}; };
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log("error.code = " + error.code)
})
```
- For more details and examples, see [Want](../../application-models/want-overview.md).
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
```
...@@ -8,65 +8,21 @@ The **wantConstant** module provides the actions, entities, and flags used in ** ...@@ -8,65 +8,21 @@ The **wantConstant** module provides the actions, entities, and flags used in **
## Modules to Import ## Modules to Import
```js ```ts
import wantConstant from '@ohos.app.ability.wantConstant'; import wantConstant from '@ohos.app.ability.wantConstant';
``` ```
## wantConstant.Action ## wantConstant.Params
Enumerates the action constants of the **Want** object. **action** specifies the operation to execute. Defines **Params** (specifying the action that can be performed) in the Want.
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description |
| ------------ | ------------------ | ---------------------- |
| ACTION_HOME | ohos.want.action.home | Action of returning to the home page. |
| ACTION_DIAL | ohos.want.action.dial | Action of launching the numeric keypad. |
| ACTION_SEARCH | ohos.want.action.search | Action of launching the search function. |
| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides wireless network settings, for example, Wi-Fi options. |
| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | Action of launching the UI for managing installed applications. |
| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | Action of launching the UI that displays the details of an application. |
| ACTION_SET_ALARM | ohos.want.action.setAlarm | Action of launching the UI for setting the alarm clock. |
| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all alarms. |
| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | Action of launching the UI for snoozing an alarm. |
| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. |
| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. |
| ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS message. |
| ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for opening a contact or picture. |
| ACTION_IMAGE_CAPTURE | ohos.want.action.imageCapture | Action of launching the UI for photographing. |
| ACTION_VIDEO_CAPTURE | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. |
| ACTION_SELECT | ohos.want.action.select | Action of launching the UI for application selection. |
| ACTION_SEND_DATA | ohos.want.action.sendData | Action of launching the UI for sending a single data record. |
| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | Action of launching the UI for sending multiple data records. |
| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | Action of requesting a media scanner to scan a file and add the file to the media library. |
| ACTION_VIEW_DATA | ohos.want.action.viewData | Action of viewing data. |
| ACTION_EDIT_DATA | ohos.want.action.editData | Action of editing data. |
| INTENT_PARAMS_INTENT | ability.want.params.INTENT | Action of displaying selection options with an action selector. |
| INTENT_PARAMS_TITLE | ability.want.params.TITLE | Title of the character sequence dialog box used with the action selector. |
| ACTION_FILE_SELECT | ohos.action.fileSelect | Action of selecting a file. |
| PARAMS_STREAM | ability.params.stream | URI of the data stream associated with the target when the data is sent. |
| ACTION_APP_ACCOUNT_AUTH | account.appAccount.action.auth | Action of providing the authentication service. |
| ACTION_MARKET_DOWNLOAD | ohos.want.action.marketDownload | Action of downloading an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| ACTION_MARKET_CROWDTEST | ohos.want.action.marketCrowdTest | Action of crowdtesting an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_SANDBOX |ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_BUNDLE_NAME |ohos.dlp.params.bundleName |Action of obtaining the DLP bundle name.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_MODULE_NAME |ohos.dlp.params.moduleName |Action of obtaining the DLP module name.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_ABILITY_NAME |ohos.dlp.params.abilityName |Action of obtaining the DLP ability name.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_INDEX |ohos.dlp.params.index |Action of obtaining the DLP index.<br>**System API**: This is a system API and cannot be called by third-party applications. |
## wantConstant.Entity
Enumerates the entity constants of the **Want** object. **entity** specifies additional information of the target ability.
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description | | Name | Value | Description |
| ------------ | ------------------ | ---------------------- | | ----------------------- | --------------------------- | ------------------------------------------------------------ |
| ENTITY_DEFAULT | entity.system.default | Default entity. The default entity is used if no entity is specified. | | DLP_PARAMS_SANDBOX | ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| ENTITY_HOME | entity.system.home | Home screen entity. | | DLP_PARAMS_BUNDLE_NAME | ohos.dlp.params.bundleName | Action of obtaining the DLP bundle name.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| ENTITY_VOICE | entity.system.voice | Voice interaction entity. | | DLP_PARAMS_MODULE_NAME | ohos.dlp.params.moduleName | Action of obtaining the DLP module name.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| ENTITY_BROWSABLE | entity.system.browsable | Browser type entity. | | DLP_PARAMS_ABILITY_NAME | ohos.dlp.params.abilityName | Action of obtaining the DLP ability name.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| ENTITY_VIDEO | entity.system.video | Video type entity. | | DLP_PARAMS_INDEX | ohos.dlp.params.index | Action of obtaining the DLP index.<br>**System API**: This is a system API and cannot be called by third-party applications.|
## wantConstant.Flags ## wantConstant.Flags
......
...@@ -35,7 +35,7 @@ Creates a **FormBindingData** object. ...@@ -35,7 +35,7 @@ Creates a **FormBindingData** object.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ | | ------ | -------------- | ---- | ------------------------------------------------------------ |
| obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.| | obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by **'formImages'**, and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {'formImages': {'key1': fd1, 'key2': fd2}}.|
**Return value** **Return value**
...@@ -48,14 +48,14 @@ Creates a **FormBindingData** object. ...@@ -48,14 +48,14 @@ Creates a **FormBindingData** object.
**Example** **Example**
```ts ```ts
import fs from '@ohos.file.fs';
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import fs from '@ohos.file.fs';
try { try {
let fd = fs.openSync('/path/to/form.png') let fd = fs.openSync('/path/to/form.png');
let obj = { let obj = {
"temperature": "21°", 'temperature': '21°',
"formImages": { "image": fd } 'formImages': { 'image': fd }
}; };
formBindingData.createFormBindingData(obj); formBindingData.createFormBindingData(obj);
} catch (error) { } catch (error) {
......
...@@ -43,7 +43,7 @@ Deletes a widget. After this API is called, the application can no longer use th ...@@ -43,7 +43,7 @@ Deletes a widget. After this API is called, the application can no longer use th
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = "12400633174999288"; let formId = '12400633174999288';
formHost.deleteForm(formId, (error) => { formHost.deleteForm(formId, (error) => {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
...@@ -92,7 +92,7 @@ Deletes a widget. After this API is called, the application can no longer use th ...@@ -92,7 +92,7 @@ Deletes a widget. After this API is called, the application can no longer use th
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = "12400633174999288"; let formId = '12400633174999288';
formHost.deleteForm(formId).then(() => { formHost.deleteForm(formId).then(() => {
console.log('formHost deleteForm success'); console.log('formHost deleteForm success');
}).catch((error) => { }).catch((error) => {
...@@ -133,7 +133,7 @@ Releases a widget. After this API is called, the application can no longer use t ...@@ -133,7 +133,7 @@ Releases a widget. After this API is called, the application can no longer use t
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = "12400633174999288"; let formId = '12400633174999288';
formHost.releaseForm(formId, (error) => { formHost.releaseForm(formId, (error) => {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
...@@ -175,7 +175,7 @@ Releases a widget. After this API is called, the application can no longer use t ...@@ -175,7 +175,7 @@ Releases a widget. After this API is called, the application can no longer use t
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = "12400633174999288"; let formId = '12400633174999288';
formHost.releaseForm(formId, true, (error) => { formHost.releaseForm(formId, true, (error) => {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
...@@ -222,7 +222,7 @@ Releases a widget. After this API is called, the application can no longer use t ...@@ -222,7 +222,7 @@ Releases a widget. After this API is called, the application can no longer use t
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = "12400633174999288"; let formId = '12400633174999288';
formHost.releaseForm(formId, true).then(() => { formHost.releaseForm(formId, true).then(() => {
console.log('formHost releaseForm success'); console.log('formHost releaseForm success');
}).catch((error) => { }).catch((error) => {
...@@ -263,7 +263,7 @@ Requests a widget update. This API uses an asynchronous callback to return the r ...@@ -263,7 +263,7 @@ Requests a widget update. This API uses an asynchronous callback to return the r
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = "12400633174999288"; let formId = '12400633174999288';
formHost.requestForm(formId, (error) => { formHost.requestForm(formId, (error) => {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
...@@ -309,7 +309,7 @@ Requests a widget update. This API uses a promise to return the result. ...@@ -309,7 +309,7 @@ Requests a widget update. This API uses a promise to return the result.
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = "12400633174999288"; let formId = '12400633174999288';
formHost.requestForm(formId).then(() => { formHost.requestForm(formId).then(() => {
console.log('formHost requestForm success'); console.log('formHost requestForm success');
}).catch((error) => { }).catch((error) => {
...@@ -351,7 +351,7 @@ Converts a temporary widget to a normal one. This API uses an asynchronous callb ...@@ -351,7 +351,7 @@ Converts a temporary widget to a normal one. This API uses an asynchronous callb
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = "12400633174999288"; let formId = '12400633174999288';
formHost.castToNormalForm(formId, (error) => { formHost.castToNormalForm(formId, (error) => {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
...@@ -397,7 +397,7 @@ Converts a temporary widget to a normal one. This API uses a promise to return t ...@@ -397,7 +397,7 @@ Converts a temporary widget to a normal one. This API uses a promise to return t
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = "12400633174999288"; let formId = '12400633174999288';
formHost.castToNormalForm(formId).then(() => { formHost.castToNormalForm(formId).then(() => {
console.log('formHost castTempForm success'); console.log('formHost castTempForm success');
}).catch((error) => { }).catch((error) => {
...@@ -438,7 +438,7 @@ Instructs the widget framework to make a widget visible. After this API is calle ...@@ -438,7 +438,7 @@ Instructs the widget framework to make a widget visible. After this API is calle
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = ["12400633174999288"]; let formId = ['12400633174999288'];
formHost.notifyVisibleForms(formId, (error) => { formHost.notifyVisibleForms(formId, (error) => {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
...@@ -484,7 +484,7 @@ Instructs the widget framework to make a widget visible. After this API is calle ...@@ -484,7 +484,7 @@ Instructs the widget framework to make a widget visible. After this API is calle
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = ["12400633174999288"]; let formId = ['12400633174999288'];
formHost.notifyVisibleForms(formId).then(() => { formHost.notifyVisibleForms(formId).then(() => {
console.log('formHost notifyVisibleForms success'); console.log('formHost notifyVisibleForms success');
}).catch((error) => { }).catch((error) => {
...@@ -525,7 +525,7 @@ Instructs the widget framework to make a widget invisible. After this API is cal ...@@ -525,7 +525,7 @@ Instructs the widget framework to make a widget invisible. After this API is cal
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = ["12400633174999288"]; let formId = ['12400633174999288'];
formHost.notifyInvisibleForms(formId, (error) => { formHost.notifyInvisibleForms(formId, (error) => {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
...@@ -571,7 +571,7 @@ Instructs the widget framework to make a widget invisible. After this API is cal ...@@ -571,7 +571,7 @@ Instructs the widget framework to make a widget invisible. After this API is cal
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = ["12400633174999288"]; let formId = ['12400633174999288'];
formHost.notifyInvisibleForms(formId).then(() => { formHost.notifyInvisibleForms(formId).then(() => {
console.log('formHost notifyInvisibleForms success'); console.log('formHost notifyInvisibleForms success');
}).catch((error) => { }).catch((error) => {
...@@ -612,7 +612,7 @@ Instructs the widget framework to make a widget updatable. After this API is cal ...@@ -612,7 +612,7 @@ Instructs the widget framework to make a widget updatable. After this API is cal
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = ["12400633174999288"]; let formId = ['12400633174999288'];
formHost.enableFormsUpdate(formId, (error) => { formHost.enableFormsUpdate(formId, (error) => {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
...@@ -658,7 +658,7 @@ Instructs the widget framework to make a widget updatable. After this API is cal ...@@ -658,7 +658,7 @@ Instructs the widget framework to make a widget updatable. After this API is cal
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = ["12400633174999288"]; let formId = ['12400633174999288'];
formHost.enableFormsUpdate(formId).then(() => { formHost.enableFormsUpdate(formId).then(() => {
console.log('formHost enableFormsUpdate success'); console.log('formHost enableFormsUpdate success');
}).catch((error) => { }).catch((error) => {
...@@ -699,7 +699,7 @@ Instructs the widget framework to make a widget not updatable. After this API is ...@@ -699,7 +699,7 @@ Instructs the widget framework to make a widget not updatable. After this API is
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = ["12400633174999288"]; let formId = ['12400633174999288'];
formHost.disableFormsUpdate(formId, (error) => { formHost.disableFormsUpdate(formId, (error) => {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
...@@ -745,7 +745,7 @@ Instructs the widget framework to make a widget not updatable. After this API is ...@@ -745,7 +745,7 @@ Instructs the widget framework to make a widget not updatable. After this API is
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formId = ["12400633174999288"]; let formId = ['12400633174999288'];
formHost.disableFormsUpdate(formId).then(() => { formHost.disableFormsUpdate(formId).then(() => {
console.log('formHost disableFormsUpdate success'); console.log('formHost disableFormsUpdate success');
}).catch((error) => { }).catch((error) => {
...@@ -842,7 +842,7 @@ try { ...@@ -842,7 +842,7 @@ try {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
} else { } else {
console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data)); console.log('formHost getAllFormsInfo, data: ${JSON.stringify(data)}');
} }
}); });
} catch(error) { } catch(error) {
...@@ -873,7 +873,7 @@ import formHost from '@ohos.app.form.formHost'; ...@@ -873,7 +873,7 @@ import formHost from '@ohos.app.form.formHost';
try { try {
formHost.getAllFormsInfo().then((data) => { formHost.getAllFormsInfo().then((data) => {
console.log('formHost getAllFormsInfo data:' + JSON.stringify(data)); console.log('formHost getAllFormsInfo data: ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
}); });
...@@ -912,11 +912,11 @@ Obtains the widget information provided by a given application on the device. Th ...@@ -912,11 +912,11 @@ Obtains the widget information provided by a given application on the device. Th
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => { formHost.getFormsInfo('com.example.ohos.formjsdemo', (error, data) => {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
} else { } else {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); console.log('formHost getFormsInfo, data: ${JSON.stringify(data)}');
} }
}); });
} catch(error) { } catch(error) {
...@@ -955,11 +955,11 @@ Obtains the widget information provided by a given application on the device. Th ...@@ -955,11 +955,11 @@ Obtains the widget information provided by a given application on the device. Th
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => { formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error, data) => {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
} else { } else {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); console.log('formHost getFormsInfo, data: ${JSON.stringify(data)}');
} }
}); });
} catch(error) { } catch(error) {
...@@ -1003,8 +1003,8 @@ Obtains the widget information provided by a given application on the device. Th ...@@ -1003,8 +1003,8 @@ Obtains the widget information provided by a given application on the device. Th
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").then((data) => { formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry').then((data) => {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); console.log('formHost getFormsInfo, data: ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
}); });
...@@ -1036,12 +1036,12 @@ Deletes invalid widgets from the list. This API uses an asynchronous callback to ...@@ -1036,12 +1036,12 @@ Deletes invalid widgets from the list. This API uses an asynchronous callback to
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formIds = new Array("12400633174999288", "12400633174999289"); let formIds = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds, (error, data) => { formHost.deleteInvalidForms(formIds, (error, data) => {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
} else { } else {
console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); console.log('formHost deleteInvalidForms, data: ${JSON.stringify(data)}');
} }
}); });
} catch(error) { } catch(error) {
...@@ -1077,9 +1077,9 @@ Deletes invalid widgets from the list. This API uses a promise to return the res ...@@ -1077,9 +1077,9 @@ Deletes invalid widgets from the list. This API uses a promise to return the res
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
try { try {
let formIds = new Array("12400633174999288", "12400633174999289"); let formIds = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds).then((data) => { formHost.deleteInvalidForms(formIds).then((data) => {
console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); console.log('formHost deleteInvalidForms, data: ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
}); });
...@@ -1118,13 +1118,13 @@ Obtains the widget state. This API uses an asynchronous callback to return the r ...@@ -1118,13 +1118,13 @@ Obtains the widget state. This API uses an asynchronous callback to return the r
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
let want = { let want = {
"deviceId": "", 'deviceId': '',
"bundleName": "ohos.samples.FormApplication", 'bundleName': 'ohos.samples.FormApplication',
"abilityName": "FormAbility", 'abilityName': 'FormAbility',
"parameters": { 'parameters': {
"ohos.extra.param.key.module_name": "entry", 'ohos.extra.param.key.module_name': 'entry',
"ohos.extra.param.key.form_name": "widget", 'ohos.extra.param.key.form_name': 'widget',
"ohos.extra.param.key.form_dimension": 2 'ohos.extra.param.key.form_dimension': 2
} }
}; };
try { try {
...@@ -1132,7 +1132,7 @@ try { ...@@ -1132,7 +1132,7 @@ try {
if (error) { if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
} else { } else {
console.log('formHost acquireFormState, data:' + JSON.stringify(data)); console.log('formHost acquireFormState, data: ${JSON.stringify(data)}');
} }
}); });
} catch(error) { } catch(error) {
...@@ -1175,18 +1175,18 @@ Obtains the widget state. This API uses a promise to return the result. ...@@ -1175,18 +1175,18 @@ Obtains the widget state. This API uses a promise to return the result.
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
let want = { let want = {
"deviceId": "", 'deviceId': '',
"bundleName": "ohos.samples.FormApplication", 'bundleName': 'ohos.samples.FormApplication',
"abilityName": "FormAbility", 'abilityName': 'FormAbility',
"parameters": { 'parameters': {
"ohos.extra.param.key.module_name": "entry", 'ohos.extra.param.key.module_name': 'entry',
"ohos.extra.param.key.form_name": "widget", 'ohos.extra.param.key.form_name': 'widget',
"ohos.extra.param.key.form_dimension": 2 'ohos.extra.param.key.form_dimension': 2
} }
}; };
try { try {
formHost.acquireFormState(want).then((data) => { formHost.acquireFormState(want).then((data) => {
console.log('formHost acquireFormState, data:' + JSON.stringify(data)); console.log('formHost acquireFormState, data: ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`); console.log(`error, code: ${error.code}, message: ${error.message}`);
}); });
...@@ -1195,9 +1195,9 @@ try { ...@@ -1195,9 +1195,9 @@ try {
} }
``` ```
## on("formUninstall") ## on('formUninstall')
on(type: "formUninstall", callback: Callback&lt;string&gt;): void on(type: 'formUninstall', callback: Callback&lt;string&gt;): void
Subscribes to widget uninstall events. This API uses an asynchronous callback to return the result. Subscribes to widget uninstall events. This API uses an asynchronous callback to return the result.
...@@ -1207,7 +1207,7 @@ Subscribes to widget uninstall events. This API uses an asynchronous callback to ...@@ -1207,7 +1207,7 @@ Subscribes to widget uninstall events. This API uses an asynchronous callback to
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| type | string | Yes | Event type. The value **formUninstall** indicates a widget uninstallation event.| | type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
| callback | Callback&lt;string&gt; | Yes| Callback used to return the widget ID.| | callback | Callback&lt;string&gt; | Yes| Callback used to return the widget ID.|
**Example** **Example**
...@@ -1216,14 +1216,14 @@ Subscribes to widget uninstall events. This API uses an asynchronous callback to ...@@ -1216,14 +1216,14 @@ Subscribes to widget uninstall events. This API uses an asynchronous callback to
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
let callback = function(formId) { let callback = function(formId) {
console.log('formHost on formUninstall, formId:' + formId); console.log('formHost on formUninstall, formId: ${formId}');
} }
formHost.on("formUninstall", callback); formHost.on('formUninstall', callback);
``` ```
## off("formUninstall") ## off('formUninstall')
off(type: "formUninstall", callback?: Callback&lt;string&gt;): void off(type: 'formUninstall', callback?: Callback&lt;string&gt;): void
Unsubscribes from widget uninstall events. This API uses an asynchronous callback to return the result. Unsubscribes from widget uninstall events. This API uses an asynchronous callback to return the result.
...@@ -1233,8 +1233,8 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac ...@@ -1233,8 +1233,8 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| type | string | Yes | Event type. The value **formUninstall** indicates a widget uninstallation event.| | type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
| callback | Callback&lt;string&gt; | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.<br> The value must be the same as that in **on("formUninstall")**.| | callback | Callback&lt;string&gt; | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.<br> The value must be the same as that in **on('formUninstall')**.|
**Example** **Example**
...@@ -1242,9 +1242,9 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac ...@@ -1242,9 +1242,9 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
let callback = function(formId) { let callback = function(formId) {
console.log('formHost on formUninstall, formId:' + formId); console.log('formHost on formUninstall, formId: ${formId}');
} }
formHost.off("formUninstall", callback); formHost.off('formUninstall', callback);
``` ```
## notifyFormsVisible ## notifyFormsVisible
...@@ -1277,7 +1277,7 @@ Instructs the widgets to make themselves visible. This API uses an asynchronous ...@@ -1277,7 +1277,7 @@ Instructs the widgets to make themselves visible. This API uses an asynchronous
```ts ```ts
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
let formIds = new Array("12400633174999288", "12400633174999289"); let formIds = new Array('12400633174999288', '12400633174999289');
try { try {
formHost.notifyFormsVisible(formIds, true, (error) => { formHost.notifyFormsVisible(formIds, true, (error) => {
if (error) { if (error) {
...@@ -1324,7 +1324,7 @@ Instructs the widgets to make themselves visible. This API uses a promise to ret ...@@ -1324,7 +1324,7 @@ Instructs the widgets to make themselves visible. This API uses a promise to ret
```ts ```ts
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
let formIds = new Array("12400633174999288", "12400633174999289"); let formIds = new Array('12400633174999288', '12400633174999289');
try { try {
formHost.notifyFormsVisible(formIds, true).then(() => { formHost.notifyFormsVisible(formIds, true).then(() => {
console.log('formHost notifyFormsVisible success'); console.log('formHost notifyFormsVisible success');
...@@ -1366,7 +1366,7 @@ Instructs the widgets to enable or disable updates. This API uses an asynchronou ...@@ -1366,7 +1366,7 @@ Instructs the widgets to enable or disable updates. This API uses an asynchronou
```ts ```ts
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
let formIds = new Array("12400633174999288", "12400633174999289"); let formIds = new Array('12400633174999288', '12400633174999289');
try { try {
formHost.notifyFormsEnableUpdate(formIds, true, (error) => { formHost.notifyFormsEnableUpdate(formIds, true, (error) => {
if (error) { if (error) {
...@@ -1413,7 +1413,7 @@ Instructs the widgets to enable or disable updates. This API uses a promise to r ...@@ -1413,7 +1413,7 @@ Instructs the widgets to enable or disable updates. This API uses a promise to r
```ts ```ts
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
let formIds = new Array("12400633174999288", "12400633174999289"); let formIds = new Array('12400633174999288', '12400633174999289');
try { try {
formHost.notifyFormsEnableUpdate(formIds, true).then(() => { formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
console.log('formHost notifyFormsEnableUpdate success'); console.log('formHost notifyFormsEnableUpdate success');
...@@ -1454,8 +1454,8 @@ Shares a specified widget with a remote device. This API uses an asynchronous ca ...@@ -1454,8 +1454,8 @@ Shares a specified widget with a remote device. This API uses an asynchronous ca
```ts ```ts
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
let formId = "12400633174999288"; let formId = '12400633174999288';
let deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"; let deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
try { try {
formHost.shareForm(formId, deviceId, (error) => { formHost.shareForm(formId, deviceId, (error) => {
if (error) { if (error) {
...@@ -1502,8 +1502,8 @@ Shares a specified widget with a remote device. This API uses a promise to retur ...@@ -1502,8 +1502,8 @@ Shares a specified widget with a remote device. This API uses a promise to retur
```ts ```ts
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
let formId = "12400633174999288"; let formId = '12400633174999288';
let deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"; let deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
try { try {
formHost.shareForm(formId, deviceId).then(() => { formHost.shareForm(formId, deviceId).then(() => {
console.log('formHost shareForm success'); console.log('formHost shareForm success');
...@@ -1545,7 +1545,7 @@ Notifies that the privacy protection status of the specified widgets changes. Th ...@@ -1545,7 +1545,7 @@ Notifies that the privacy protection status of the specified widgets changes. Th
```ts ```ts
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
let formIds = new Array("12400633174999288", "12400633174999289"); let formIds = new Array('12400633174999288', '12400633174999289');
try { try {
formHost.notifyFormsPrivacyProtected(formIds, true, (error) => { formHost.notifyFormsPrivacyProtected(formIds, true, (error) => {
if (error) { if (error) {
...@@ -1590,7 +1590,7 @@ Notifies that the privacy protection status of the specified widgets changes. Th ...@@ -1590,7 +1590,7 @@ Notifies that the privacy protection status of the specified widgets changes. Th
```ts ```ts
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
let formIds = new Array("12400633174999288", "12400633174999289"); let formIds = new Array('12400633174999288', '12400633174999289');
try { try {
formHost.notifyFormsPrivacyProtected(formIds, true).then(() => { formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
console.log('formHost notifyFormsPrivacyProtected success'); console.log('formHost notifyFormsPrivacyProtected success');
......
...@@ -31,7 +31,6 @@ Describes widget information. ...@@ -31,7 +31,6 @@ Describes widget information.
| isDefault | boolean | Yes | No | Whether the widget is the default one. | | isDefault | boolean | Yes | No | Whether the widget is the default one. |
| updateEnabled | boolean | Yes | No | Whether the widget is updatable. | | updateEnabled | boolean | Yes | No | Whether the widget is updatable. |
| formVisibleNotify | boolean | Yes | No | Whether to send a notification when the widget is visible. | | formVisibleNotify | boolean | Yes | No | Whether to send a notification when the widget is visible. |
| relatedBundleName | string | Yes | No | Name of the associated bundle to which the widget belongs. |
| scheduledUpdateTime | string | Yes | No | Time when the widget was updated. | | scheduledUpdateTime | string | Yes | No | Time when the widget was updated. |
| formConfigAbility | string | Yes | No | Configuration ability of the widget, that is, the ability corresponding to the option in the selection box displayed when the widget is long pressed. | | formConfigAbility | string | Yes | No | Configuration ability of the widget, that is, the ability corresponding to the option in the selection box displayed when the widget is long pressed. |
| updateDuration | number | Yes | No | Update period of the widget.| | updateDuration | number | Yes | No | Update period of the widget.|
...@@ -93,16 +92,16 @@ Enumerates the widget parameters. ...@@ -93,16 +92,16 @@ Enumerates the widget parameters.
| Name | Value | Description | | Name | Value | Description |
| ----------- | ---- | ------------ | | ----------- | ---- | ------------ |
| IDENTITY_KEY | "ohos.extra.param.key.form_identity" | Widget ID. | | IDENTITY_KEY | 'ohos.extra.param.key.form_identity' | Widget ID. |
| DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | Widget dimension. | | DIMENSION_KEY | 'ohos.extra.param.key.form_dimension' | Widget dimension. |
| NAME_KEY | "ohos.extra.param.key.form_name" | Widget name. | | NAME_KEY | 'ohos.extra.param.key.form_name' | Widget name. |
| MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | Name of the module to which the widget belongs. | | MODULE_NAME_KEY | 'ohos.extra.param.key.module_name' | Name of the module to which the widget belongs. |
| WIDTH_KEY | "ohos.extra.param.key.form_width" | Widget width. | | WIDTH_KEY | 'ohos.extra.param.key.form_width' | Widget width. |
| HEIGHT_KEY | "ohos.extra.param.key.form_height" | Widget height. | | HEIGHT_KEY | 'ohos.extra.param.key.form_height' | Widget height. |
| TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | Temporary widget. | | TEMPORARY_KEY | 'ohos.extra.param.key.form_temporary' | Temporary widget. |
| ABILITY_NAME_KEY | "ohos.extra.param.key.ability_name" | Ability name. | | ABILITY_NAME_KEY | 'ohos.extra.param.key.ability_name' | Ability name. |
| DEVICE_ID_KEY | "ohos.extra.param.key.device_id" | Device ID. | | DEVICE_ID_KEY | 'ohos.extra.param.key.device_id' | Device ID. |
| BUNDLE_NAME_KEY | "ohos.extra.param.key.bundle_name" | Key that specifies the target bundle name.| | BUNDLE_NAME_KEY | 'ohos.extra.param.key.bundle_name' | Key that specifies the target bundle name.|
## FormDimension ## FormDimension
......
...@@ -39,7 +39,7 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback ...@@ -39,7 +39,7 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
```ts ```ts
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288"; let formId = '12400633174999288';
try { try {
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => { formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error) { if (error) {
...@@ -86,7 +86,7 @@ Sets the next refresh time for a widget. This API uses a promise to return the r ...@@ -86,7 +86,7 @@ Sets the next refresh time for a widget. This API uses a promise to return the r
```ts ```ts
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288"; let formId = '12400633174999288';
try { try {
formProvider.setFormNextRefreshTime(formId, 5).then(() => { formProvider.setFormNextRefreshTime(formId, 5).then(() => {
console.log(`formProvider setFormNextRefreshTime success`); console.log(`formProvider setFormNextRefreshTime success`);
...@@ -127,9 +127,9 @@ Updates a widget. This API uses an asynchronous callback to return the result. ...@@ -127,9 +127,9 @@ Updates a widget. This API uses an asynchronous callback to return the result.
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288"; let formId = '12400633174999288';
try { try {
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj, (error, data) => { formProvider.updateForm(formId, obj, (error, data) => {
if (error) { if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`); console.log(`callback error, code: ${error.code}, message: ${error.message})`);
...@@ -176,8 +176,8 @@ Updates a widget. This API uses a promise to return the result. ...@@ -176,8 +176,8 @@ Updates a widget. This API uses a promise to return the result.
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288"; let formId = '12400633174999288';
let obj = formBindingData.createFormBindingData({ temperature: "22c", time: "22:00" }); 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`);
...@@ -221,7 +221,7 @@ try { ...@@ -221,7 +221,7 @@ try {
if (error) { if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`); console.log(`callback error, code: ${error.code}, message: ${error.message})`);
} else { } else {
console.log('formProvider getFormsInfo, data: ' + JSON.stringify(data)); console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
} }
}); });
} catch (error) { } catch (error) {
...@@ -258,14 +258,14 @@ import formProvider from '@ohos.app.form.formProvider'; ...@@ -258,14 +258,14 @@ import formProvider from '@ohos.app.form.formProvider';
const filter: formInfo.FormInfoFilter = { const filter: formInfo.FormInfoFilter = {
// get info of forms belong to module entry. // get info of forms belong to module entry.
moduleName: "entry" moduleName: 'entry'
}; };
try { try {
formProvider.getFormsInfo(filter, (error, data) => { formProvider.getFormsInfo(filter, (error, data) => {
if (error) { if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`); console.log(`callback error, code: ${error.code}, message: ${error.message})`);
} else { } else {
console.log('formProvider getFormsInfo, data: ' + JSON.stringify(data)); console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
} }
}); });
} catch (error) { } catch (error) {
...@@ -308,11 +308,11 @@ import formProvider from '@ohos.app.form.formProvider'; ...@@ -308,11 +308,11 @@ import formProvider from '@ohos.app.form.formProvider';
const filter: formInfo.FormInfoFilter = { const filter: formInfo.FormInfoFilter = {
// get info of forms belong to module entry. // get info of forms belong to module entry.
moduleName: "entry" moduleName: 'entry'
}; };
try { try {
formProvider.getFormsInfo(filter).then((data) => { formProvider.getFormsInfo(filter).then((data) => {
console.log('formProvider getFormsInfo, data:' + JSON.stringify(data)); console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log(`promise error, code: ${error.code}, message: ${error.message})`); console.log(`promise error, code: ${error.code}, message: ${error.message})`);
}); });
...@@ -335,7 +335,7 @@ Requests to publish a widget carrying data to the widget host. This API uses an ...@@ -335,7 +335,7 @@ Requests to publish a widget carrying data to the widget host. This API uses an
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | | ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" | | want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' |
| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.| | formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the widget ID.| | callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the widget ID.|
...@@ -353,20 +353,20 @@ import formBindingData from '@ohos.app.form.formBindingData'; ...@@ -353,20 +353,20 @@ import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let want = { let want = {
abilityName: "FormAbility", abilityName: 'FormAbility',
parameters: { parameters: {
"ohos.extra.param.key.form_dimension": 2, 'ohos.extra.param.key.form_dimension': 2,
"ohos.extra.param.key.form_name": "widget", 'ohos.extra.param.key.form_name': 'widget',
"ohos.extra.param.key.module_name": "entry" 'ohos.extra.param.key.module_name': 'entry'
} }
}; };
try { try {
let obj = formBindingData.createFormBindingData({ temperature: "22c", time: "22:00" }); let obj = formBindingData.createFormBindingData({ temperature: '22c', time: '22:00' });
formProvider.requestPublishForm(want, obj, (error, data) => { formProvider.requestPublishForm(want, obj, (error, data) => {
if (error) { if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`); console.log(`callback error, code: ${error.code}, message: ${error.message})`);
} else { } else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data)); console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
} }
}); });
} catch (error) { } catch (error) {
...@@ -388,7 +388,7 @@ Requests to publish a widget to the widget host. This API uses an asynchronous c ...@@ -388,7 +388,7 @@ Requests to publish a widget to the widget host. This API uses an asynchronous c
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ----------------------------------- | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" | | want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the widget ID.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the widget ID.|
**Error codes** **Error codes**
...@@ -404,11 +404,11 @@ Requests to publish a widget to the widget host. This API uses an asynchronous c ...@@ -404,11 +404,11 @@ Requests to publish a widget to the widget host. This API uses an asynchronous c
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let want = { let want = {
abilityName: "FormAbility", abilityName: 'FormAbility',
parameters: { parameters: {
"ohos.extra.param.key.form_dimension": 2, 'ohos.extra.param.key.form_dimension': 2,
"ohos.extra.param.key.form_name": "widget", 'ohos.extra.param.key.form_name': 'widget',
"ohos.extra.param.key.module_name": "entry" 'ohos.extra.param.key.module_name': 'entry'
} }
}; };
try { try {
...@@ -416,7 +416,7 @@ try { ...@@ -416,7 +416,7 @@ try {
if (error) { if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`); console.log(`callback error, code: ${error.code}, message: ${error.message})`);
} else { } else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data)); console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
} }
}); });
} catch (error) { } catch (error) {
...@@ -438,7 +438,7 @@ Requests to publish a widget to the widget host. This API uses a promise to retu ...@@ -438,7 +438,7 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" | | want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' |
| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. | | formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. |
**Return value** **Return value**
...@@ -460,16 +460,16 @@ Requests to publish a widget to the widget host. This API uses a promise to retu ...@@ -460,16 +460,16 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let want = { let want = {
abilityName: "FormAbility", abilityName: 'FormAbility',
parameters: { parameters: {
"ohos.extra.param.key.form_dimension": 2, 'ohos.extra.param.key.form_dimension': 2,
"ohos.extra.param.key.form_name": "widget", 'ohos.extra.param.key.form_name': 'widget',
"ohos.extra.param.key.module_name": "entry" 'ohos.extra.param.key.module_name': 'entry'
} }
}; };
try { try {
formProvider.requestPublishForm(want).then((data) => { formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data)); console.log('formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log(`promise error, code: ${error.code}, message: ${error.message})`); console.log(`promise error, code: ${error.code}, message: ${error.message})`);
}); });
...@@ -506,11 +506,11 @@ try { ...@@ -506,11 +506,11 @@ try {
} else { } else {
if (isSupported) { if (isSupported) {
var want = { var want = {
abilityName: "FormAbility", abilityName: 'FormAbility',
parameters: { parameters: {
"ohos.extra.param.key.form_dimension": 2, 'ohos.extra.param.key.form_dimension': 2,
"ohos.extra.param.key.form_name": "widget", 'ohos.extra.param.key.form_name': 'widget',
"ohos.extra.param.key.module_name": "entry" 'ohos.extra.param.key.module_name': 'entry'
} }
}; };
try { try {
...@@ -518,7 +518,7 @@ try { ...@@ -518,7 +518,7 @@ try {
if (error) { if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`); console.log(`callback error, code: ${error.code}, message: ${error.message})`);
} else { } else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data)); console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
} }
}); });
} catch (error) { } catch (error) {
...@@ -557,16 +557,16 @@ try { ...@@ -557,16 +557,16 @@ try {
formProvider.isRequestPublishFormSupported().then((isSupported) => { formProvider.isRequestPublishFormSupported().then((isSupported) => {
if (isSupported) { if (isSupported) {
var want = { var want = {
abilityName: "FormAbility", abilityName: 'FormAbility',
parameters: { parameters: {
"ohos.extra.param.key.form_dimension": 2, 'ohos.extra.param.key.form_dimension': 2,
"ohos.extra.param.key.form_name": "widget", 'ohos.extra.param.key.form_name': 'widget',
"ohos.extra.param.key.module_name": "entry" 'ohos.extra.param.key.module_name': 'entry'
} }
}; };
try { try {
formProvider.requestPublishForm(want).then((data) => { formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data)); console.log('formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log(`promise error, code: ${error.code}, message: ${error.message})`); console.log(`promise error, code: ${error.code}, message: ${error.message})`);
}); });
......
# @ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry) # @ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)
The **AbilityDelegatorRegistry** module provides APIs for storing the global registers of the registered **AbilityDelegator** and **AbilityDelegatorArgs** objects. You can use the APIs to obtain the **AbilityDelegator** and **AbilityDelegatorArgs** objects of an application. The **AbilityDelegatorRegistry** module provides APIs for storing the global registers of the registered **AbilityDelegator** and **AbilityDelegatorArgs** objects. You can use the APIs to obtain the **AbilityDelegator** and **AbilityDelegatorArgs** objects of an application. The APIs can be used only in the test framework.
> **NOTE** > **NOTE**
> >
...@@ -43,7 +43,7 @@ Obtains the **AbilityDelegator** object of the application. ...@@ -43,7 +43,7 @@ Obtains the **AbilityDelegator** object of the application.
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
``` ```
...@@ -65,8 +65,8 @@ Obtains the **AbilityDelegatorArgs** object of the application. ...@@ -65,8 +65,8 @@ Obtains the **AbilityDelegatorArgs** object of the application.
**Example** **Example**
```ts ```ts
var args = AbilityDelegatorRegistry.getArguments(); let args = AbilityDelegatorRegistry.getArguments();
console.info("getArguments bundleName:" + args.bundleName); console.info('getArguments bundleName: ${args.bundleName}');
console.info("getArguments testCaseNames:" + args.testCaseNames); console.info('getArguments testCaseNames: ${args.testCaseNames}');
console.info("getArguments testRunnerClassName:" + args.testRunnerClassName); console.info('getArguments testRunnerClassName: ${args.testRunnerClassName}');
``` ```
...@@ -49,13 +49,13 @@ Updates the configuration. This API uses an asynchronous callback to return the ...@@ -49,13 +49,13 @@ Updates the configuration. This API uses an asynchronous callback to return the
**Example** **Example**
```ts ```ts
var config = { let config = {
language: 'chinese' language: 'chinese'
} };
abilityManager.updateConfiguration(config, () => { abilityManager.updateConfiguration(config, () => {
console.log('------------ updateConfiguration -----------'); console.log('------------ updateConfiguration -----------');
}) });
``` ```
## updateConfiguration ## updateConfiguration
...@@ -83,15 +83,15 @@ Updates the configuration. This API uses a promise to return the result. ...@@ -83,15 +83,15 @@ Updates the configuration. This API uses a promise to return the result.
**Example** **Example**
```ts ```ts
var config = { let config = {
language: 'chinese' language: 'chinese'
} };
abilityManager.updateConfiguration(config).then(() => { abilityManager.updateConfiguration(config).then(() => {
console.log('updateConfiguration success'); console.log('updateConfiguration success');
}).catch((err) => { }).catch((err) => {
console.log('updateConfiguration fail'); console.log('updateConfiguration fail');
}) });
``` ```
## getAbilityRunningInfos ## getAbilityRunningInfos
...@@ -114,7 +114,7 @@ Obtains the ability running information. This API uses an asynchronous callback ...@@ -114,7 +114,7 @@ Obtains the ability running information. This API uses an asynchronous callback
```ts ```ts
abilityManager.getAbilityRunningInfos((err,data) => { abilityManager.getAbilityRunningInfos((err,data) => {
console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data)); console.log('getAbilityRunningInfos err: ${err}, data: ${JSON.stringify(data)}');
}); });
``` ```
...@@ -138,115 +138,8 @@ Obtains the ability running information. This API uses a promise to return the r ...@@ -138,115 +138,8 @@ Obtains the ability running information. This API uses a promise to return the r
```ts ```ts
abilityManager.getAbilityRunningInfos().then((data) => { abilityManager.getAbilityRunningInfos().then((data) => {
console.log("getAbilityRunningInfos data: " + JSON.stringify(data)) console.log('getAbilityRunningInfos data: ${JSON.stringify(data)}');
}).catch((err) => { }).catch((err) => {
console.log("getAbilityRunningInfos err: " + err) console.log('getAbilityRunningInfos err: ${JSON.stringify(err)}');
}); });
``` ```
## getExtensionRunningInfos<sup>9+</sup>
getExtensionRunningInfos(upperLimit: number, callback: AsyncCallback\<Array\<ExtensionRunningInfo>>): void
Obtains the extension running information. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
| callback | AsyncCallback\<Array\<[ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)>> | Yes | Callback used to return the result. |
**Example**
```ts
var upperLimit = 0;
abilityManager.getExtensionRunningInfos(upperLimit, (err,data) => {
console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
```
## getExtensionRunningInfos<sup>9+</sup>
getExtensionRunningInfos(upperLimit: number): Promise\<Array\<ExtensionRunningInfo>>
Obtains the extension running information. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<Array\<[ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)>> | Promise used to return the result.|
**Example**
```ts
var upperLimit = 0;
abilityManager.getExtensionRunningInfos(upperLimit).then((data) => {
console.log("getAbilityRunningInfos data: " + JSON.stringify(data));
}).catch((err) => {
console.log("getAbilityRunningInfos err: " + err);
})
```
## getTopAbility<sup>9+</sup>
getTopAbility(callback: AsyncCallback\<ElementName>): void;
Obtains the top ability, which is the ability that has the window focus. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback\<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | Callback used to return the result. |
**Example**
```ts
abilityManager.getTopAbility((err,data) => {
console.log("getTopAbility err: " + err + " data: " + JSON.stringify(data));
});
```
## getTopAbility<sup>9+</sup>
getTopAbility(): Promise\<ElementName>;
Obtains the top ability, which is the ability that has the window focus. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<[ElementName](js-apis-bundleManager-elementName.md)>| Promise used to return the result.|
**Example**
```ts
abilityManager.getTopAbility().then((data) => {
console.log("getTopAbility data: " + JSON.stringify(data));
}).catch((err) => {
console.log("getTopAbility err: " + err);
})
```
...@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an ...@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
...@@ -32,7 +32,7 @@ Checks whether this application is undergoing a stability test. This API uses an ...@@ -32,7 +32,7 @@ Checks whether this application is undergoing a stability test. This API uses an
appManager.isRunningInStabilityTest((err, flag) => { appManager.isRunningInStabilityTest((err, flag) => {
console.log('error: ${JSON.stringify(err)}'); console.log('error: ${JSON.stringify(err)}');
console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}'); console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}');
}) });
``` ```
...@@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a ...@@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.| | Promise&lt;boolean&gt; | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
...@@ -71,9 +71,9 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -71,9 +71,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| | Promise&lt;boolean&gt; | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
...@@ -95,9 +95,9 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -95,9 +95,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
...@@ -105,7 +105,7 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -105,7 +105,7 @@ Checks whether this application is running on a RAM constrained device. This API
appManager.isRamConstrainedDevice((err, data) => { appManager.isRamConstrainedDevice((err, data) => {
console.log('error: ${JSON.stringify(err)}'); console.log('error: ${JSON.stringify(err)}');
console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}'); console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}');
}) });
``` ```
## appManager.getAppMemorySize ## appManager.getAppMemorySize
...@@ -118,9 +118,9 @@ Obtains the memory size of this application. This API uses a promise to return t ...@@ -118,9 +118,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the memory size, in MB.| | Promise&lt;number&gt; | Promise used to return the memory size, in MB.|
**Example** **Example**
...@@ -142,9 +142,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb ...@@ -142,9 +142,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the memory size, in MB.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the memory size, in MB.|
**Example** **Example**
......
# @ohos.application.Configuration (Configuration) # @ohos.application.Configuration (Configuration)
The **Configuration** module defines environment change information. The **Configuration** module defines environment change information. **Configuration** is an interface definition and is used only for field declaration.
> **NOTE** > **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> This module is deprecated since API version 9. You are advised to use [@ohos.app.ability.Configuration](js-apis-app-ability-configuration.md) instead. > This module is deprecated since API version 9. You are advised to use [@ohos.app.ability.Configuration](js-apis-app-ability-configuration.md) instead.
## Modules to Import
```ts
import Configuration from '@ohos.application.Configuration'
```
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| language<sup>8+</sup> | string | Yes| Yes| Language of the application, for example, **zh**.| | language<sup>8+</sup> | string | Yes| Yes| Language of the application, for example, **zh**.|
| colorMode<sup>8+</sup> | [ColorMode](js-apis-application-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.| | colorMode<sup>8+</sup> | [ColorMode](js-apis-application-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
| direction<sup>9+</sup> | [Direction](js-apis-application-configurationConstant.md#configurationconstantdirection9) | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
| screenDensity<sup>9+</sup> | [ScreenDensity](js-apis-application-configurationConstant.md#configurationconstantscreendensity9) | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).|
| displayId<sup>9+</sup> | number | Yes| No| ID of the display where the application is located.|
| hasPointerDevice<sup>9+</sup> | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.|
For details about the fields, see the **ohos.application.Configuration.d.ts** file. For details about the fields, see the **ohos.application.Configuration.d.ts** file.
**Example** **Example**
```ts ```ts
import hilog from '@ohos.hilog';
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import Window from '@ohos.window'; import Window from '@ohos.window';
...@@ -41,13 +30,9 @@ export default class EntryAbility extends UIAbility { ...@@ -41,13 +30,9 @@ export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: Window.WindowStage) { onWindowStageCreate(windowStage: Window.WindowStage) {
let envCallback = { let envCallback = {
onConfigurationUpdated(config) { onConfigurationUpdated(config) {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`) console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`);
let language = config.language; let language = config.language;
let colorMode = config.colorMode; let colorMode = config.colorMode;
let direction = config.direction;
let screenDensity = config.screenDensity;
let displayId = config.displayId;
let hasPointerDevice = config.hasPointerDevice;
} }
}; };
...@@ -56,12 +41,10 @@ export default class EntryAbility extends UIAbility { ...@@ -56,12 +41,10 @@ export default class EntryAbility extends UIAbility {
windowStage.loadContent('pages/index', (err, data) => { windowStage.loadContent('pages/index', (err, data) => {
if (err.code) { if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); console.error('failed to load the content, error: + ${JSON.stringify(err)}');
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return; return;
} }
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); console.info('Succeeded in loading the content, data: + ${JSON.stringify(data)}');
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
}); });
} }
} }
......
...@@ -23,33 +23,3 @@ You can obtain the value of this constant by calling the **ConfigurationConstant ...@@ -23,33 +23,3 @@ You can obtain the value of this constant by calling the **ConfigurationConstant
| COLOR_MODE_NOT_SET | -1 | Unspecified color mode.| | COLOR_MODE_NOT_SET | -1 | Unspecified color mode.|
| COLOR_MODE_DARK | 0 | Dark mode.| | COLOR_MODE_DARK | 0 | Dark mode.|
| COLOR_MODE_LIGHT | 1 | Light mode.| | COLOR_MODE_LIGHT | 1 | Light mode.|
## ConfigurationConstant.Direction<sup>9+</sup>
You can obtain the value of this constant by calling the **ConfigurationConstant.Direction** API.
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Value| Description|
| -------- | -------- | -------- |
| DIRECTION_NOT_SET | -1 | Unspecified direction.|
| DIRECTION_VERTICAL | 0 | Vertical direction.|
| DIRECTION_HORIZONTAL | 1 | Horizontal direction.|
## ConfigurationConstant.ScreenDensity<sup>9+</sup>
You can obtain the value of this constant by calling the **ConfigurationConstant.ScreenDensity** API.
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Value| Description|
| -------- | -------- | -------- |
| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.|
| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.|
| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.|
| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.|
| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.|
| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.|
| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.|
...@@ -11,7 +11,7 @@ The **EnvironmentCallback** module provides APIs, such as **onConfigurationUpdat ...@@ -11,7 +11,7 @@ The **EnvironmentCallback** module provides APIs, such as **onConfigurationUpdat
## Modules to Import ## Modules to Import
```ts ```ts
import EnvironmentCallback from "@ohos.application.EnvironmentCallback"; import EnvironmentCallback from '@ohos.application.EnvironmentCallback';
``` ```
...@@ -41,37 +41,37 @@ Called when the system memory level changes. ...@@ -41,37 +41,37 @@ Called when the system memory level changes.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| level | [MemoryLevel](js-apis-application-abilityConstant.md#abilityconstantmemorylevel) | Yes| New memory level.| | level | [MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | Yes| New memory level.|
**Example** **Example**
```ts ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
var callbackId; let callbackId;
export default class EntryAbility extends UIAbility { export default class EntryAbility extends UIAbility {
onCreate() { onCreate() {
console.log("MyAbility onCreate") console.log('MyAbility onCreate');
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:" + level); console.log('onMemoryLevel level: ${level}');
}
} }
};
// 1. Obtain an applicationContext object. // 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext; let applicationContext = globalThis.applicationContext;
// 2. Register a listener for the environment changes through the applicationContext object. // 2. Register a listener for the environment changes through the applicationContext object.
callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback); callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId)); console.log('registerEnvironmentCallback number: ${JSON.stringify(callbackId)}');
} }
onDestroy() { onDestroy() {
let applicationContext = globalThis.applicationContext; let applicationContext = globalThis.applicationContext;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error)); console.log('unregisterEnvironmentCallback success, err: ${JSON.stringify(error)}');
}); });
} }
} }
......
...@@ -35,7 +35,7 @@ Creates a **FormBindingData** object. ...@@ -35,7 +35,7 @@ Creates a **FormBindingData** object.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ | | ------ | -------------- | ---- | ------------------------------------------------------------ |
| obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.| | obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by **'formImages'**, and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {'formImages': {'key1': fd1, 'key2': fd2}}.|
**Return value** **Return value**
...@@ -52,13 +52,13 @@ import formBindingData from '@ohos.application.formBindingData'; ...@@ -52,13 +52,13 @@ import formBindingData from '@ohos.application.formBindingData';
import fs from '@ohos.file.fs'; import fs from '@ohos.file.fs';
try { try {
let fd = fs.openSync('/path/to/form.png') let fd = fs.openSync('/path/to/form.png');
let obj = { let obj = {
"temperature": "21°", 'temperature': '21°',
"formImages": { "image": fd } 'formImages': { 'image': fd }
}; };
formBindingData.createFormBindingData(obj); formBindingData.createFormBindingData(obj);
} catch (error.code) { } catch (error) {
console.log('catch error, error:' + JSON.stringify(error)); console.log('catch error, error: ${JSON.stringify(error)}');
} }
``` ```
...@@ -49,7 +49,6 @@ Enumerates the widget types. ...@@ -49,7 +49,6 @@ Enumerates the widget types.
| Name | Value | Description | | Name | Value | Description |
| ----------- | ---- | ------------ | | ----------- | ---- | ------------ |
| JS | 1 | JS widget. | | JS | 1 | JS widget. |
| eTS<sup>9+<sup> | 2 | eTS widget.|
## ColorMode ## ColorMode
...@@ -94,48 +93,10 @@ Enumerates the widget parameters. ...@@ -94,48 +93,10 @@ Enumerates the widget parameters.
| Name | Value | Description | | Name | Value | Description |
| ----------- | ---- | ------------ | | ----------- | ---- | ------------ |
| IDENTITY_KEY<sup>9+</sup> | "ohos.extra.param.key.form_identity" | Widget ID.<br>**System API**: This is a system API. | | IDENTITY_KEY | 'ohos.extra.param.key.form_identity' | Widget ID.<br>**System API**: This is a system API. |
| DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | Widget dimension. | | DIMENSION_KEY | 'ohos.extra.param.key.form_dimension' | Widget dimension. |
| NAME_KEY | "ohos.extra.param.key.form_name" | Widget name. | | NAME_KEY | 'ohos.extra.param.key.form_name' | Widget name. |
| MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | Name of the module to which the widget belongs. | | MODULE_NAME_KEY | 'ohos.extra.param.key.module_name' | Name of the module to which the widget belongs. |
| WIDTH_KEY | "ohos.extra.param.key.form_width" | Widget width. | | WIDTH_KEY | 'ohos.extra.param.key.form_width' | Widget width. |
| HEIGHT_KEY | "ohos.extra.param.key.form_height" | Widget height. | | HEIGHT_KEY | 'ohos.extra.param.key.form_height' | Widget height. |
| TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | Temporary widget. | | TEMPORARY_KEY | 'ohos.extra.param.key.form_temporary' | Temporary widget. |
| ABILITY_NAME_KEY<sup>9+</sup> | "ohos.extra.param.key.ability_name" | Ability name. |
| DEVICE_ID_KEY<sup>9+</sup> | "ohos.extra.param.key.device_id" | Device ID. |
| BUNDLE_NAME_KEY<sup>9+</sup> | "ohos.extra.param.key.bundle_name" | Key that specifies the target bundle name.|
## FormDimension<sup>9+</sup>
Enumerates the widget dimensions.
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| Dimension_1_2 <sup>9+</sup> | 1 | 1 x 2. |
| Dimension_2_2 <sup>9+</sup> | 2 | 2 x 2. |
| Dimension_2_4 <sup>9+</sup> | 3 | 2 x 4. |
| Dimension_4_4 <sup>9+</sup> | 4 | 4 x 4. |
| Dimension_2_1 <sup>9+</sup> | 5 | 2 x 1. |
## FormInfoFilter<sup>9+</sup>
Defines the widget information filter. Only the widget information that meets the filter is returned.
**System capability**: SystemCapability.Ability.Form
| Name | Description |
| ----------- | ------------ |
| moduleName<sup>9+</sup> | Optional. Only the information about the widget whose **moduleName** is the same as the provided value is returned.<br>If this parameter is not set, **moduleName** is not used for filtering.|
## VisibilityType<sup>9+</sup>
Enumerates the visibility types of the widget.
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| FORM_VISIBLE<sup>9+<sup> | 1 | The widget is visible.|
| FORM_INVISIBLE<sup>9+<sup> | 2 | The widget is invisible.|
...@@ -33,10 +33,10 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback ...@@ -33,10 +33,10 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
```ts ```ts
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288"; let formId = '12400633174999288';
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => { formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error.code) { if (error.code) {
console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error)); console.log('formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}');
} }
}); });
``` ```
...@@ -67,11 +67,11 @@ Sets the next refresh time for a widget. This API uses a promise to return the r ...@@ -67,11 +67,11 @@ Sets the next refresh time for a widget. This API uses a promise to return the r
```ts ```ts
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288"; let formId = '12400633174999288';
formProvider.setFormNextRefreshTime(formId, 5).then(() => { formProvider.setFormNextRefreshTime(formId, 5).then(() => {
console.log('formProvider setFormNextRefreshTime success'); console.log('formProvider setFormNextRefreshTime success');
}).catch((error) => { }).catch((error) => {
console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error)); console.log('formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}');
}); });
``` ```
...@@ -97,11 +97,11 @@ Updates a widget. This API uses an asynchronous callback to return the result. ...@@ -97,11 +97,11 @@ Updates a widget. This API uses an asynchronous callback to return the result.
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288"; let formId = '12400633174999288';
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj, (error, data) => { formProvider.updateForm(formId, obj, (error, data) => {
if (error.code) { if (error.code) {
console.log('formProvider updateForm, error:' + JSON.stringify(error)); console.log('formProvider updateForm, error: ${JSON.stringify(error)}');
} }
}); });
``` ```
...@@ -133,316 +133,11 @@ Updates a widget. This API uses a promise to return the result. ...@@ -133,316 +133,11 @@ Updates a widget. This API uses a promise to return the result.
import formBindingData from '@ohos.application.formBindingData'; import formBindingData from '@ohos.application.formBindingData';
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288"; let formId = '12400633174999288';
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj).then(() => { formProvider.updateForm(formId, obj).then(() => {
console.log('formProvider updateForm success'); console.log('formProvider updateForm success');
}).catch((error) => { }).catch((error) => {
console.log('formProvider updateForm, error:' + JSON.stringify(error)); console.log('formProvider updateForm, error: ${JSON.stringify(error)}');
}); });
``` ```
## getFormsInfo<sup>9+</sup>
getFormsInfo(callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void
Obtains the application's widget information on the device. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback&lt;Array&lt;[formInfo.FormInfo](./js-apis-application-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the information obtained.|
**Example**
```ts
import formProvider from '@ohos.app.form.formProvider';
formProvider.getFormsInfo((error, data) => {
if (error.code) {
console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
} else {
console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
}
});
```
## getFormsInfo<sup>9+</sup>
getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void
Obtains the application's widget information that meets a filter criterion on the device. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| filter | [formInfo.FormInfoFilter](./js-apis-application-formInfo.md#forminfofilter) | Yes| Filter criterion.|
| callback | AsyncCallback&lt;Array&lt;[formInfo.FormInfo](./js-apis-application-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the information obtained.|
**Example**
```ts
import formInfo from '@ohos.application.formInfo';
import formProvider from '@ohos.app.form.formProvider';
const filter : formInfo.FormInfoFilter = {
// get info of forms belong to module entry.
moduleName : "entry"
};
formProvider.getFormsInfo(filter, (error, data) => {
if (error.code) {
console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
} else {
console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
}
});
```
## getFormsInfo<sup>9+</sup>
getFormsInfo(filter?: formInfo.FormInfoFilter): Promise&lt;Array&lt;formInfo.FormInfo&gt;&gt;
Obtains the application's widget information on the device. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| filter | [formInfo.FormInfoFilter](./js-apis-application-formInfo.md) | No| Filter criterion.|
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;Array&lt;[formInfo.FormInfo](./js-apis-application-formInfo.md#forminfo-1)&gt;&gt; | Promise used to return the information obtained.|
**Example**
```ts
import formInfo from '@ohos.application.formInfo';
import formProvider from '@ohos.app.form.formProvider';
const filter : formInfo.FormInfoFilter = {
// get info of forms belong to module entry.
moduleName : "entry"
};
formProvider.getFormsInfo(filter).then((data) => {
console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
}).catch((error) => {
console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
});
```
## requestPublishForm<sup>9+</sup>
requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<string>): void
Requests to publish a widget carrying data to the widget host. This API uses an asynchronous callback to return the result. This API is usually called by the home screen.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" |
| formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the widget ID.|
**Example**
```ts
import formBindingData from '@ohos.application.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
let want = {
abilityName: "FormAbility",
parameters: {
"ohos.extra.param.key.form_dimension": 2,
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.module_name": "entry"
}
};
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
formProvider.requestPublishForm(want, obj, (error, data) => {
if (error.code) {
console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
} else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
}
});
```
## requestPublishForm<sup>9+</sup>
requestPublishForm(want: Want, callback: AsyncCallback&lt;string&gt;): void
Requests to publish a widget to the widget host. This API uses an asynchronous callback to return the result. This API is usually called by the home screen.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the widget ID.|
**Example**
```ts
import formProvider from '@ohos.app.form.formProvider';
let want = {
abilityName: "FormAbility",
parameters: {
"ohos.extra.param.key.form_dimension": 2,
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.module_name": "entry"
}
};
formProvider.requestPublishForm(want, (error, data) => {
if (error.code) {
console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
} else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
}
});
```
## requestPublishForm<sup>9+</sup>
requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData): Promise&lt;string&gt;
Requests to publish a widget to the widget host. This API uses a promise to return the result. This API is usually called by the home screen.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" |
| formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;string&gt; | Promise used to return the widget ID.|
**Example**
```ts
import formProvider from '@ohos.app.form.formProvider';
let want = {
abilityName: "FormAbility",
parameters: {
"ohos.extra.param.key.form_dimension": 2,
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.module_name": "entry"
}
};
formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
}).catch((error) => {
console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
});
```
## isRequestPublishFormSupported<sup>9+<sup>
isRequestPublishFormSupported(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether a widget can be published to the widget host. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return whether the widget can be published to the widget host.|
**Example**
```ts
formProvider.isRequestPublishFormSupported((error, isSupported) => {
if (error.code) {
console.log('formProvider isRequestPublishFormSupported, error:' + JSON.stringify(error));
} else {
if (isSupported) {
let want = {
abilityName: "FormAbility",
parameters: {
"ohos.extra.param.key.form_dimension": 2,
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.module_name": "entry"
}
};
formProvider.requestPublishForm(want, (error, data) => {
if (error.code) {
console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
} else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
}
});
}
}
});
```
## isRequestPublishFormSupported<sup>9+</sup>
isRequestPublishFormSupported(): Promise&lt;boolean&gt;
Checks whether a widget can be published to the widget host. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Ability.Form
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return whether the widget can be published to the widget host.|
**Example**
```ts
formProvider.isRequestPublishFormSupported().then((isSupported) => {
if (isSupported) {
let want = {
abilityName: "FormAbility",
parameters: {
"ohos.extra.param.key.form_dimension": 2,
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.module_name": "entry"
}
};
formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
}).catch((error) => {
console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
});
}
}).catch((error) => {
console.log('formProvider isRequestPublishFormSupported, error:' + JSON.stringify(error));
});
```
...@@ -10,7 +10,7 @@ The **StaticSubscriberExtensionAbility** module provides Extension abilities for ...@@ -10,7 +10,7 @@ The **StaticSubscriberExtensionAbility** module provides Extension abilities for
## Modules to Import ## Modules to Import
```ts ```ts
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility' import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility';
``` ```
## StaticSubscriberExtensionAbility.onReceiveEvent ## StaticSubscriberExtensionAbility.onReceiveEvent
...@@ -32,12 +32,9 @@ Callback of the common event of a static subscriber. ...@@ -32,12 +32,9 @@ Callback of the common event of a static subscriber.
**Example** **Example**
```ts ```ts
var StaticSubscriberExtensionAbility = requireNapi("application.StaticSubscriberExtensionAbility") class MyStaticSubscriberExtensionAbility extends StaticSubscriberExtensionAbility {
{ onReceiveEvent(event) {
onReceiveEvent(event){ console.log('onReceiveEvent, event: ${JSON.stringify(event)}');
console.log('onReceiveEvent,event:' + event.code);
} }
} }
export default MyStaticSubscriberExtensionAbility
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册