You need to sign in or sign up before continuing.
提交 e74ddfc5 编写于 作者: W wangshuainan1 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into master

Signed-off-by: Nwangshuainan1 <wangshuainan1@huawei.com>
......@@ -231,7 +231,7 @@ zh-cn/application-dev/reference/apis/js-apis-audio.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-camera.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-image.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-media.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-i18n.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-intl.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @HelloCrease
......@@ -365,4 +365,7 @@ zh-cn/application-dev/reference/apis/js-apis-buffer.md @zengyawen
zh-cn/application-dev/reference/js-service-widget-ui @HelloCrease
zh-cn/application-dev/website.md @zengyawen
zh-cn/application-dev/faqs/ @zengyawen
zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @zengyawen
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-userfilemanager.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md @zengyawen
zh-cn/application-dev/reference/apis/Readme-CN.md @zengyawen
\ No newline at end of file
......@@ -81,7 +81,7 @@ import Ability from '@ohos.application.Ability'
```ts
export default class MySequenceable {
num: number = 0
str: String = ""
str: string = ""
constructor(num, string) {
this.num = num
......
......@@ -26,70 +26,30 @@
| -------- | -------- | -------- |
| ohos.sensor | sensor.on(sensorType, callback:AsyncCallback&lt;Response&gt;): void | Subscribes to data changes of a type of sensor.|
| ohos.sensor | sensor.once(sensorType, callback:AsyncCallback&lt;Response&gt;): void | Subscribes to only one data change of a type of sensor.|
| ohos.sensor | sensor.off(sensorType, callback:AsyncCallback&lt;void&gt;): void | Unsubscribes from sensor data changes.|
| ohos.sensor | sensor.off(sensorType, callback?:AsyncCallback&lt;void&gt;): void | Unsubscribes from sensor data changes.|
## How to Develop
1. To obtain data from a type of sensor, configure the requested permissions in the **config.json** file.
```
"reqPermissions": [
{
"name": "ohos.permission.ACCELEROMETER",
"reason": "",
"usedScene": {
"ability": [
"sensor.index.MainAbility",
".MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GYROSCOPE",
"reason": "",
"usedScene": {
"ability": [
"sensor.index.MainAbility",
".MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.ACTIVITY_MOTION",
"reason": "ACTIVITY_MOTION_TEST",
"usedScene": {
"ability": [
"sensor.index.MainAbility",
".MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.READ_HEALTH_DATA",
"reason": "HEALTH_DATA_TEST",
"usedScene": {
"ability": [
"sensor.index.MainAbility",
".MainAbility"
],
"when": "inuse"
}
}
]
```
1. Before obtaining data from a type of sensor, check whether the required permission has been configured.<br>
The system provides the following sensor-related permissions:
- ohos.permission.ACCELEROMETER
- ohos.permission.GYROSCOPE
- ohos.permission.ACTIVITY_MOTION
- ohos.permission.READ_HEALTH_DATA
For details about how to configure a permission, see [Declaring Permissions](../security/accesstoken-guidelines.md).
2. Subscribe to data changes of a type of sensor.
```
import sensor from "@ohos.sensor"
sensor.on(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data){
console.info("Subscription succeeded. data = " + data); // The call is successful, and the obtained sensor data is printed.
}
);
import sensor from "@ohos.sensor";
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function(data){
console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // Data is obtained.
});
```
The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**.
......@@ -99,11 +59,8 @@
3. Unsubscribe from sensor data changes.
```
import sensor from "@ohos.sensor"
sensor.off(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function() {
console.info("Succeeded in unsubscribing from acceleration sensor data."); // The unsubscription is successful, and the result is printed.
}
);
import sensor from "@ohos.sensor";
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER);
```
The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**.
......@@ -113,11 +70,10 @@
4. Subscribe to only one data change of a type of sensor.
```
import sensor from "@ohos.sensor"
sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) {
console.info("Data obtained successfully. data=" + data); // The call is successful, and the obtained sensor data is printed.
}
);
import sensor from "@ohos.sensor";
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function(data) {
console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // Data is obtained.
});
```
The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**.
......@@ -127,11 +83,12 @@
If the API fails to be called, you are advised to use the **try/catch** statement to capture error information that may occur in the code. Example:
```
import sensor from "@ohos.sensor";
try {
sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) {
console.info("Data obtained successfully. data=" + data); // The call is successful, and the obtained sensor data is printed.
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function(data) {
console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // Data is obtained.
});
} catch (error) {
console.error(error);
console.error("Failed to get sensor data");
}
```
```
\ No newline at end of file
......@@ -52,15 +52,12 @@ The following modules work cooperatively to implement OpenHarmony sensors: Senso
1. To obtain data of the following sensors, you must claim the required permissions.
Table 7 Sensor data permissions
| Sensor | Permission | Sensitivity | Permission Description |
| ------------------------- | -------------------------------- | ------------ | ----------------------- |
| Acceleration sensor, uncalibrated acceleration sensor, and linear acceleration sensor| ohos.permission.ACCELEROMETER | system_grant | Allows an application to subscribe to data of these acceleration-related sensors in the motion category.|
| Gyroscope sensor and uncalibrated gyroscope sensor | ohos.permission.GYROSCOPE | system_grant | Allows an application to subscribe to data of the gyroscope-related sensors in the motion category.|
| Pedometer sensor | ohos.permission.ACTIVITY_MOTION | user_grant | Allows an application to subscribe to the motion status. |
| Heart rate sensor | ohos.permission.READ_HEALTH_DATA | user_grant | Allows an application to read health data. |
| Sensor | Permission | Sensitivity | Permission Description |
| ------------------------- | -------------------------------- | ------------ | ----------------------- |
| Acceleration sensor, uncalibrated acceleration sensor, and linear acceleration sensor| ohos.permission.ACCELEROMETER | system_grant | Allows an application to subscribe to data of these acceleration-related sensors in the motion category.|
| Gyroscope sensor and uncalibrated gyroscope sensor | ohos.permission.GYROSCOPE | system_grant | Allows an application to subscribe to data of the gyroscope-related sensors in the motion category.|
| Pedometer sensor | ohos.permission.ACTIVITY_MOTION | user_grant | Allows an application to subscribe to the motion status. |
| Heart rate sensor | ohos.permission.READ_HEALTH_DATA | user_grant | Allows an application to read health data. |
2. The APIs for subscribing to and unsubscribing from sensor data work in pairs. If you do not need sensor data, call the unsubscription API to stop sensor data reporting.
......@@ -22,42 +22,7 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
## How to Develop
1. Declare the permissions required for controlling vibrators on the hardware device in the `config.json` file.
```
"reqPermissions": [
{
"name": "ohos.permission.ACCELEROMETER",
"reason": "",
"usedScene": {
"ability": [
".MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.VIBRATE",
"reason": "",
"usedScene": {
"ability": [
".MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.ACTIVITY_MOTION",
"reason": "",
"usedScene": {
"ability": [
".MainAbility"
],
"when": "inuse"
}
}
]
```
1. Before using the vibrator on a device, you must declare the **ohos.permission.VIBRATE** permission. For details about how to configure a permission, see [Declaring Permissions](../security/accesstoken-guidelines.md).
2. Trigger the device to vibrate.
......
......@@ -23,4 +23,4 @@ The vibrator is a Misc device that consists of four modules: Vibrator API, Vibra
## Constraints
When using a vibrator, you must declare the **ohos.permission.VIBRATE** permission before you can control the vibration effect. The authorization mode of this permission is **system_grant**.
When using a vibrator, you must declare the **ohos.permission.VIBRATE** permission before you can control the vibration effect.
......@@ -6,8 +6,8 @@ This module provides APIs for accessing ability-specific resources. You can use
> **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 APIs of this module can be used only in the stage model.
> - 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 APIs of this module can be used only in the stage model.
## Usage
......
......@@ -4,12 +4,12 @@ The **wantConstant** module provides the actions, entities, and flags used in **
> **NOTE**
>
> The initial APIs of this module are supported since API 6. 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 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import wantConstant from '@ohos.ability.wantConstant'
```js
import wantConstant from '@ohos.ability.wantConstant';
```
## wantConstant.Action
......@@ -46,8 +46,13 @@ Enumerates the action constants of the **Want** object.
| 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. |
| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. |
| ACTION_MARKER_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. |
| ACTION_MARKET_CROWDTEST <sup>9+</sup> | 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<sup>9+</sup> |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<sup>9+</sup> |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<sup>9+</sup> |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<sup>9+</sup> |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<sup>9+</sup> |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
......
......@@ -78,7 +78,7 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility {
## WindowExtensionAbility.onWindowReady
onWindowReady(window: Window): void
onWindowReady(window: window.Window): void
Called when a window is ready.
......@@ -88,7 +88,7 @@ Called when a window is ready.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| window | [Window](js-apis-window.md) | Yes| Current **Window** instance.|
| window | [window.Window](js-apis-window.md#window) | Yes| Current **Window** instance.|
**Example**
......@@ -99,7 +99,7 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility {
onWindowReady(window) {
window.loadContent('WindowExtAbility/pages/index1').then(() => {
window.getProperties().then((pro) => {
console.log("WindowExtension " + JSON.stringify(pro));
console.log('WindowExtension ' + JSON.stringify(pro));
})
window.show();
})
......
......@@ -4,7 +4,7 @@ The **Ability** module manages the ability lifecycle and context, such as creati
This module provides the following common ability-related functions:
- [Caller](#caller): implements sending of sequenceable data to the target ability when an ability (caller) invokes the target ability (callee).
- [Caller](#caller): implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability).
- [Callee](#callee): implements callbacks for registration and deregistration of caller notifications.
> **NOTE**
......@@ -22,12 +22,12 @@ import Ability from '@ohos.application.Ability';
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.|
| launchWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters for starting the ability.|
| lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.|
| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.|
| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.|
| launchWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters for starting the ability.|
| lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.|
| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.|
## Ability.onCreate
......@@ -39,13 +39,13 @@ Called to initialize the service logic when an ability is created.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.|
| param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
**Example**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.|
| param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
**Example**
```js
class myAbility extends Ability {
onCreate(want, param) {
......@@ -65,12 +65,12 @@ Called when a **WindowStage** is created for this ability.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
**Example**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
**Example**
```js
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
......@@ -88,8 +88,8 @@ Called when the **WindowStage** is destroyed for this ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
**Example**
```js
class myAbility extends Ability {
onWindowStageDestroy() {
......@@ -109,12 +109,12 @@ Called when the **WindowStage** is restored during the migration of this ability
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
**Example**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
**Example**
```js
class myAbility extends Ability {
onWindowStageRestore(windowStage) {
......@@ -132,8 +132,8 @@ Called when this ability is destroyed to clear resources.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
**Example**
```js
class myAbility extends Ability {
onDestroy() {
......@@ -151,8 +151,8 @@ Called when this ability is switched from the background to the foreground.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
**Example**
```js
class myAbility extends Ability {
onForeground() {
......@@ -170,8 +170,8 @@ Called when this ability is switched from the foreground to the background.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
**Example**
```js
class myAbility extends Ability {
onBackground() {
......@@ -191,18 +191,18 @@ Called to save data during the ability migration preparation process.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes| **want** parameter.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes| **want** parameter.|
**Return value**
| Type| Description|
| -------- | -------- |
| AbilityConstant.OnContinueResult | Continuation result.|
**Example**
| Type| Description|
| -------- | -------- |
| AbilityConstant.OnContinueResult | Continuation result.|
**Example**
```js
import AbilityConstant from "@ohos.application.AbilityConstant"
class myAbility extends Ability {
......@@ -225,20 +225,17 @@ Called when the ability startup mode is set to singleton.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.|
| launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.|
**Example**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.|
| launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.|
**Example**
```js
class myAbility extends Ability {
onNewWant(want, launchParams) {
onNewWant(want) {
console.log('onNewWant, want:' + want.abilityName);
if (launchParams.launchReason === AbilityConstant.LaunchReason.CONTINUATION) {
console.log('onNewWant, launchReason is continuation');
}
}
}
```
......@@ -254,12 +251,12 @@ Called when the configuration of the environment where the ability is running is
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
**Example**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
**Example**
```js
class myAbility extends Ability {
onConfigurationUpdated(config) {
......@@ -278,12 +275,12 @@ Dumps client information.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| params | Array\<string> | Yes| Parameters in the form of a command.|
**Example**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| params | Array\<string> | Yes| Parameters in the form of a command.|
**Example**
```js
class myAbility extends Ability {
dump(params) {
......@@ -293,11 +290,35 @@ Dumps client information.
}
```
## Ability.onMemoryLevel
onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system has decided to adjust the memory level. For example, this API can be used when there is not enough memory to run as many background processes as possible.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| level | [AbilityConstant.MemoryLevel](js-apis-application-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**
```js
class myAbility extends Ability {
onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level));
}
}
```
## Caller
Implements sending of sequenceable data to the target ability when an ability (caller) invokes the target ability (callee).
Implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability).
## Caller.call
......@@ -310,19 +331,19 @@ Sends sequenceable data to the target ability.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return a response.|
**Example**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return a response.|
**Example**
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{ // Custom sequenceable data structure
......@@ -383,19 +404,19 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;rpc.MessageParcel&gt; | Promise used to return the sequenceable data from the target ability.|
**Example**
| Type| Description|
| -------- | -------- |
| Promise&lt;rpc.MessageParcel&gt; | Promise used to return the sequenceable data from the target ability.|
**Example**
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
......@@ -455,8 +476,8 @@ Releases the caller interface of the target ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
**Example**
```js
import Ability from '@ohos.application.Ability';
var caller;
......@@ -492,12 +513,12 @@ Registers a callback that is invoked when the stub on the target ability is disc
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.|
**Example**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.|
**Example**
```js
import Ability from '@ohos.application.Ability';
var caller;
......@@ -540,12 +561,13 @@ Registers a caller notification callback, which is invoked when the target abili
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities.|
| callback | CalleeCallBack | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities.|
| callback | CalleeCallBack | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.|
**Example**
**Example**
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
......@@ -595,9 +617,9 @@ Deregisters a caller notification callback, which is invoked when the target abi
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Registered notification message string.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Registered notification message string.|
**Example**
......@@ -618,17 +640,16 @@ Deregisters a caller notification callback, which is invoked when the target abi
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| (msg: string) | function | Yes| No| Prototype of the listener function registered by the caller.|
| (msg: string) | function | Yes| No| Prototype of the listener function registered by the caller.|
## CalleeCallBack
## CalleeCallBack
(indata: rpc.MessageParcel): rpc.Sequenceable;
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the listener function registered by the callee.|
| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the listener function registered by the callee.|
......@@ -65,7 +65,7 @@ Enumerates ability continuation results.
## AbilityConstant.WindowMode
Enumerates the window modes when an ability is started.
Enumerates the window modes in which an ability can be displayed at startup.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -76,3 +76,15 @@ Enumerates the window modes when an ability is started.
| WINDOW_MODE_SPLIT_PRIMARY | 100 | The ability is displayed in the primary window in split-screen mode. |
| WINDOW_MODE_SPLIT_SECONDARY | 101 | The ability is displayed in the secondary window in split-screen mode. |
| WINDOW_MODE_FLOATING | 102 | The ability is displayed in a floating window.|
## AbilityConstant.MemoryLevel
Enumerates the memory levels.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value| Description |
| --- | --- | --- |
| MEMORY_LEVEL_MODERATE | 0 | Moderate memory usage. |
| MEMORY_LEVEL_LOW | 1 | Low memory usage. |
| MEMORY_LEVEL_CRITICAL | 2 | High memory usage. |
......@@ -875,3 +875,265 @@ abilityDelegator.finishTest(msg, 0).then(() => {
console.info("finishTest promise");
});
```
### addAbilityStageMonitor<sup>9+</sup>
addAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<void>): void;
Adds an **AbilityStageMonitor** instance to monitor the lifecycle state changes of an ability stage. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
```js
var abilityDelegator;
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.addAbilityStageMonitor(monitor, (err : any) => {
console.info("addAbilityStageMonitor callback");
});
```
### addAbilityStageMonitor<sup>9+</sup>
addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
Adds an **AbilityStageMonitor** instance to monitor the lifecycle state changes of an ability stage. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
**Return value**
| Type | Description |
| -------------- | ------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
var abilityDelegator;
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.addAbilityStageMonitor(monitor).then(() => {
console.info("addAbilityStageMonitor promise");
});
```
### removeAbilityStageMonitor<sup>9+</sup>
removeAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<void>): void;
Removes an **AbilityStageMonitor** instance from the application memory. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
```js
var abilityDelegator;
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.removeAbilityStageMonitor(monitor, (err : any) => {
console.info("removeAbilityStageMonitor callback");
});
```
### removeAbilityStageMonitor<sup>9+</sup>
removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
Removes an **AbilityStageMonitor** object from the application memory. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
**Return value**
| Type | Description |
| -------------- | ------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
var abilityDelegator;
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.removeAbilityStageMonitor(monitor).then(() => {
console.info("removeAbilityStageMonitor promise");
});
```
### waitAbilityStageMonitor<sup>9+</sup>
waitAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<AbilityStage>): void;
Waits for an **AbilityStage** instance that matches the conditions set in an **AbilityStageMonitor** instance and returns the **AbilityStage** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
| callback | AsyncCallback\<AbilityStage> | Yes | Callback used to return the result. If the operation is successful, an **AbilityStage** instance is returned. Otherwise, no value is returned. |
**Example**
```js
var abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.waitAbilityStageMonitor(monitor, (err : any, data : any) => {
console.info("waitAbilityStageMonitor callback");
});
```
### waitAbilityStageMonitor<sup>9+</sup>
waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise\<AbilityStage>;
Waits for an **AbilityStage** instance that matches the conditions set in an **AbilityStageMonitor** instance and returns the **AbilityStage** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
| timeout | number | No | Maximum waiting time, in milliseconds.|
**Return value**
| Type | Description |
| -------------- | ------------------- |
| Promise\<AbilityStage> | Promise used to return the result. If the operation is successful, an **AbilityStage** instance is returned. Otherwise, no value is returned.|
**Example**
```js
var abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.waitAbilityStageMonitor(monitor).then((data : any) => {
console.info("waitAbilityStageMonitor promise");
});
```
### waitAbilityStageMonitor<sup>9+</sup>
waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout: number, callback: AsyncCallback\<AbilityStage>): void;
Waits a period of time for an **AbilityStage** instance that matches the conditions set in an **AbilityStageMonitor** instance and returns the **AbilityStage** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
| timeout | number | No | Maximum waiting time, in milliseconds.|
| callback | AsyncCallback\<AbilityStage> | Yes | Callback used to return the result. If the operation is successful, an **AbilityStage** instance is returned. Otherwise, no value is returned. |
**Example**
```js
var abilityDelegator;
var timeout = 100;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.waitAbilityStageMonitor(monitor, timeout, (err : any, data : any) => {
console.info("waitAbilityStageMonitor callback");
});
```
## AbilityStageMonitor
Provides conditions for matching **AbilityStage** instances. The most recently matched **AbilityStage** instance is saved in an **AbilityStageMonitor** instance.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable| Writable| Description |
| ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ |
| moduleName<sup>9+</sup> | string | Yes | Yes | Module name of the **AbilityStage** instance.|
| srcEntrance<sup>9+</sup> | string | Yes | Yes | Source path of the **AbilityStage** instance.|
......@@ -11,7 +11,7 @@ The **AbilityDelegatorArgs** module provides a global register to store the regi
The ability delegator arguments are obtained by calling **getArguments** in **AbilityDelegatorRegistry**.
```js
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
var args = AbilityDelegatorRegistry.getArguments();
```
......
......@@ -89,6 +89,31 @@ Called when the global configuration is updated.
}
}
```
## AbilityStage.onMemoryLevel
onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system has decided to adjust the memory level. For example, this API can be used when there is not enough memory to run as many background processes as possible.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| level | [AbilityConstant.MemoryLevel](js-apis-application-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**
```js
class MyAbilityStage extends AbilityStage {
onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level));
}
}
```
## AbilityStage.context
context: AbilityStageContext;
......
......@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
......@@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value**
| 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.|
| 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.|
**Example**
......@@ -72,9 +72,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value**
| 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.|
| 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.|
**Example**
......@@ -96,9 +96,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| 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**
......@@ -119,9 +119,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Size of the application memory.|
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Size of the application memory.|
**Example**
......@@ -143,9 +143,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | No| Size of the application memory.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | No| Size of the application memory.|
**Example**
......@@ -157,14 +157,12 @@ Obtains the memory size of this application. This API uses an asynchronous callb
```
## appManager.getProcessRunningInfos<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](#appmanagergetprocessrunninginformation9) instead.
getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>;
Obtains information about the running processes. This API uses a promise to return the result.
> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](#appmanagergetprocessrunninginformation9) instead.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -187,14 +185,12 @@ Obtains information about the running processes. This API uses a promise to retu
## appManager.getProcessRunningInfos<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](#appmanagergetprocessrunninginformation9-1) instead.
getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): void;
Obtains information about the running processes. This API uses an asynchronous callback to return the result.
> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](#appmanagergetprocessrunninginformation9-1) instead.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -228,7 +224,7 @@ Obtains information about the running processes. This API uses a promise to retu
| Type| Description|
| -------- | -------- |
| Promise\<Array\<ProcessRunningInformation>> | Promise used to return the process information.|
| Promise\<Array\<[ProcessRunningInformation](#processrunninginformation)>> | Promise used to return the process information.|
**Example**
......@@ -254,7 +250,7 @@ Obtains information about the running processes. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<ProcessRunningInformation>> | No| Callback used to return the process information.|
| callback | AsyncCallback\<Array\<[ProcessRunningInformation](#processrunninginformation)>> | No| Callback used to return the process information.|
**Example**
......@@ -269,7 +265,7 @@ Obtains information about the running processes. This API uses an asynchronous c
registerApplicationStateObserver(observer: ApplicationStateObserver): number;
Registers an observer to listen for the state of all applications.
Registers an observer to listen for the state changes of all applications.
**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
......@@ -307,9 +303,9 @@ Registers an observer to listen for the state of all applications.
## appManager.registerApplicationStateObserver<sup>9+</sup>
registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array<string>): number;
registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array\<string>): number;
Registers an observer to listen for the state of a specified application.
Registers an observer to listen for the state changes of a specified application.
**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
......@@ -322,7 +318,7 @@ Registers an observer to listen for the state of a specified application.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observer | [ApplicationStateObserver](#applicationstateobserver) | No| Numeric code of the observer.|
| bundleNameList | Array<string> | No| **bundleName** array to be registered for listening. The maximum value is 128.|
| bundleNameList | Array<string> | No| **bundleName** array of the application. A maximum of 128 bundle names can be passed.|
**Example**
......@@ -359,7 +355,7 @@ Deregisters the application state observer. This API uses an asynchronous callba
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observerId | number | No| Numeric code of the observer.|
......@@ -491,10 +487,10 @@ Kills a process by bundle name and account ID. This API uses a promise to return
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
**Example**
......@@ -525,11 +521,11 @@ Kills a process by bundle name and account ID. This API uses an asynchronous cal
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example**
......@@ -708,9 +704,14 @@ Called when the application state changes.
**Example**
```js
import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver'
const foregroundApplicationInfo = ApplicationStateObserver.onForegroundApplicationChanged();
console.log('-------- foregroundApplicationInfo: ---------', foregroundApplicationInfo);
var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
}
}
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
## ApplicationStateObserver.onAbilityStateChanged<sup>8+</sup>
......@@ -732,9 +733,13 @@ Called when the ability state changes.
**Example**
```js
import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver'
const abilityStateChangedInfo = ApplicationStateObserver.onAbilityStateChanged();
console.log('-------- abilityStateChangedInfo: ---------', abilityStateChangedInfo);
var applicationStateObserver = {
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
}
}
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
## ApplicationStateObserver.onProcessCreated<sup>8+</sup>
......@@ -756,9 +761,13 @@ Called when a process is created.
**Example**
```js
import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver'
const processCreatedInfo = ApplicationStateObserver.onProcessCreated();
console.log('-------- processCreatedInfo: ---------', processCreatedInfo);
var applicationStateObserver = {
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
}
}
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
## ApplicationStateObserver.onProcessDied<sup>8+</sup>
......@@ -775,14 +784,46 @@ Called when a process is terminated.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| processData | ProcessData | No| Process information.|
| processData | [ProcessData](#processdata) | No| Process information.|
**Example**
```js
import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver'
const processDiedInfo = ApplicationStateObserver.onProcessDied();
console.log('-------- processDiedInfo: ---------', processDiedInfo);
var applicationStateObserver = {
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
}
}
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
## ApplicationStateObserver.onProcessStateChanged<sup>9+</sup>
onProcessStateChanged(processData: ProcessData): void;
Called when the process state changes.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| processData | [ProcessData](#processdata) | No| Process information.|
**Example**
```js
var applicationStateObserver = {
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
}
}
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
## AppStateData
......@@ -815,7 +856,7 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo);
## ProcessData
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
......@@ -824,19 +865,19 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo);
| pid<sup>8+</sup> | number | Yes | No | Process ID. |
| bundleName<sup>8+</sup> | string | Yes | No | Bundle name of an application. |
| uid<sup>8+</sup> | number | Yes | No | User ID. |
| isContinuousTask<sup>9+</sup> | boolean | Yes | No | Whether the process is a continuous task. |
| isKeepAlive<sup>9+</sup> | boolean | Yes | No | Whether the process remains active. |
## ProcessRunningInfo
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| pid<sup>9+</sup> | Read only | number | No | Process ID. |
| uid<sup>9+</sup> | Read only | number | No | User ID.|
| processName<sup>9+</sup> | Read only | string | No | Process name.|
| bundleNames<sup>9+</sup> | Read only | Array\<string> | No | **bundleName** array in the running processes.|
| pid<sup>8+</sup> | Read only | number | No | Process ID. |
| uid<sup>8+</sup> | Read only | number | No | User ID.|
| processName<sup>8+</sup> | Read only | string | No | Process name.|
| bundleNames<sup>8+</sup> | Read only | Array\<string> | No | **bundleName** array in the running processes.|
## ApplicationStateObserver
......@@ -850,3 +891,44 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo);
| [onAbilityStateChanged<sup>8+</sup>](#applicationstateobserveronabilitystatechanged8) | AsyncCallback\<void> | Yes | No | Callback invoked when the ability state changes. |
| [onProcessCreated<sup>8+</sup>](#applicationstateobserveronprocesscreated8) | AsyncCallback\<void> | Yes | No | Callback invoked when a process is created. |
| [onProcessDied<sup>8+</sup>](#applicationstateobserveronprocessdied8) | AsyncCallback\<void> | Yes | No | Callback invoked when a process is destroyed. |
## ProcessRunningInformation
Defines the process running information.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| pid<sup>9+</sup> | Read only | number | No | Process ID. |
| uid<sup>9+</sup> | Read only | number | No | User ID.|
| processName<sup>9+</sup> | Read only | string | No | Process name.|
| bundleNames<sup>9+</sup> | Read only | Array\<string> | No | **bundleName** array in the running processes.|
## ApplicationState<sup>9+</sup>
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description |
| -------------------- | --- | --------------------------------- |
| STATE_CREATE | 1 | State indicating that the application is being created. |
| STATE_FOREGROUND | 2 | State indicating that the application is running in the foreground. |
| STATE_ACTIVE | 3 | State indicating that the application is active. |
| STATE_BACKGROUND | 4 | State indicating that the application is running in the background. |
| STATE_DESTROY | 5 | State indicating that the application is destroyed. |
## ProcessState<sup>9+</sup>
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description |
| -------------------- | --- | --------------------------------- |
| STATE_CREATE | 1 | State indicating that the process is being created. |
| STATE_FOREGROUND | 2 | State indicating that the process is running in the foreground. |
| STATE_ACTIVE | 3 | State indicating that the process is active. |
| STATE_BACKGROUND | 4 | State indicating that the process is running in the background. |
| STATE_DESTROY | 5 | State indicating that the process is destroyed. |
......@@ -12,6 +12,9 @@ When compared with **[LinkedList](js-apis-linkedlist.md)**, **ArrayList** is mor
**Recommended use case**: Use **ArrayList** when elements in a container need to be frequently read.
This topic uses the following to identify the use of generics:
- T: Type
## Modules to Import
```ts
......@@ -72,7 +75,7 @@ Adds an element at the end of this container.
let result1 = arrayList.add(1);
let b = [1, 2, 3];
let result2 = arrayList.add(b);
let c = {name: "lala", age: "13"};
let c = {name: "Dylon", age: "13"};
let result3 = arrayList.add(false);
```
......@@ -124,9 +127,9 @@ Checks whether this container has the specified element.
```ts
let arrayList = new ArrayList();
let result = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
arrayList.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
let result1 = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
let result = arrayList.has("squirrel");
arrayList.add("squirrel");
let result1 = arrayList.has("squirrel");
```
### getIndexOf
......@@ -361,7 +364,7 @@ arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
arrayList.forEach((value, index) => {
console.log("value:" + value, index);
console.log(`value:${value}`, index);
});
```
......@@ -623,14 +626,14 @@ arrayList.add(4);
// Method 1:
for (let item of arrayList) {
console.log("value:" + item);
console.log(`value:${item}`);
}
// Method 2:
let iter = arrayList[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
console.log("value:" + temp);
console.log(`value:${temp}`);
temp = iter.next().value;
}
```
# ExtensionAbilityInfo
The **ExtensionAbilityInfo** module provides Extension ability information. Unless otherwise specified, all attributes are obtained through [getBundleInfo](js-apis-Bundle.md#bundlegetbundleinfo), and flags are obtained through [GET_BUNDLE_DEFAULT](js-apis-Bundle.md#bundleflag).
> **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 **ExtensionAbilityInfo** module provides Extension ability information. Unless otherwise specified, all attributes are obtained through **GET_BUNDLE_DEFAULT**.
## ExtensionAbilityInfo
**System capability**: SystemCapability.BundleManager.BundleFramework
......
# LauncherAbilityInfo
The **LauncherAbilityInfo** module provides information about a launcher ability.
The **LauncherAbilityInfo** module provides information about the launcher ability, which is obtained through [innerBundleManager.getLauncherAbilityInfos](js-apis-Bundle-InnerBundleManager.md).
> **NOTE**
>
......@@ -12,8 +12,8 @@ The **LauncherAbilityInfo** module provides information about a launcher ability
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable| Writable| Description |
| --------------- | ---------------------------------------------------- | ---- | ---- | ------------------------------------ |
| Name | Type | Readable| Writable| Description |
| --------------- | ---------------------------------------------------- | ---- | ---- | -------------------------------------- |
| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application information of the launcher ability.|
| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | No | Element name of the launcher ability. |
| labelId | number | Yes | No | Label ID of the launcher ability. |
......
# ShortcutInfo
The **ShortcutInfo** module provides shortcut information defined in the configuration file.
The **ShortcutInfo** module provides shortcut information defined in the configuration file. For details about the configuration in the FA model, see [config.json](../../quick-start/package-structure.md). For details about the configuration in the stage model, see [Internal Structure of the shortcuts Attribute](../../quick-start/stage-structure.md#internal-structure-of-the-shortcuts-attribute).
> **NOTE**
>
......
......@@ -812,7 +812,7 @@ Obtains the zoom ratio range. This API uses an asynchronous callback to return t
| Name | Type | Mandatory| Description |
| -------- | ------------------------------ | ---- | ------------------------ |
| callback | AsyncCallback<Array<number\>\> | Yes | Callback used to return the result.|
| callback | AsyncCallback<Array<number\>\> | Yes | Callback used to return an array containing the minimum and maximum zoom ratios.|
**Example**
......@@ -838,7 +838,7 @@ Obtains the zoom ratio range. This API uses a promise to return the result.
| Type | Description |
| ------------------------ | ------------------------------------------- |
| Promise<Array<number\>\> | Promise used to return the zoom ratio range.|
| Promise<Array<number\>\> | Promise used to return an array containing the minimum and maximum zoom ratios.|
**Example**
......
......@@ -12,6 +12,9 @@ Double-ended queue (deque) is a sequence container implemented based on the queu
**Recommended use case**: Use **Deque** when you need to frequently insert or remove elements at both the ends of a container.
This topic uses the following to identify the use of generics:
- T: Type
## Modules to Import
```ts
......@@ -64,7 +67,7 @@ deque.insertFront("a");
deque.insertFront(1);
let b = [1, 2, 3];
deque.insertFront(b);
let c = {name : "lala", age : "13"};
let c = {name : "Dylon", age : "13"};
deque.insertFront(false);
```
......@@ -90,7 +93,7 @@ deque.insertEnd("a");
deque.insertEnd(1);
let b = [1, 2, 3];
deque.insertEnd(b);
let c = {name : "lala", age : "13"};
let c = {name : "Dylon", age : "13"};
deque.insertEnd(false);
```
......@@ -118,9 +121,9 @@ Checks whether this container has the specified element.
```ts
let deque = new Deque();
let result = deque.has("Ahfbrgrbgnutfodgorrogorg");
deque.insertFront("Ahfbrgrbgnutfodgorrogorg");
let result1 = deque.has("Ahfbrgrbgnutfodgorrogorg");
let result = deque.has("squirrel");
deque.insertFront("squirrel");
let result1 = deque.has("squirrel");
```
### popFirst
......
......@@ -4,7 +4,7 @@ The **EffectKit** module provides basic image processing capabilities, including
This module provides the following classes:
- [Filter](#filter): a class that provides the effect chain.
- [Filter](#filter): a class that provides the effect chain, which is a linked list of image processing effects.
- [Color](#color): a class used to store the color picked.
- [ColorPicker](#colorpicker): a smart color picker.
......@@ -155,7 +155,7 @@ Obtains the main color of the image and writes the result to a **[Color](#color)
```js
colorPicker.getMainColor().then(color => {
console.log('Succeeded in getting main color.');
console.info("color[ARGB]=" + color.alpha + "," + color.red + "," + color.green + "," + color.blue);
console.info(`color[ARGB]=${color.alpha},${color.red},${color.green},${color.blue}`);
}).catch(error => {
console.log('Failed to get main color.');
})
......
......@@ -3,7 +3,7 @@
The **FormInfo** module provides widget information and state.
> **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.
## Modules to Import
......@@ -120,3 +120,14 @@ Enumerates the widget dimensions.
| 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
Defines the widget information filter. Only the widget information that meets the filter is returned.
**System capability**: SystemCapability.Ability.Form
| Name | Yes | Description |
| ----------- | ---- | ------------ |
| moduleName<sup>9+</sup> | No | Module name.|
......@@ -3,7 +3,7 @@
The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release.
> **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.
## Modules to Import
......@@ -183,7 +183,7 @@ Obtains the application's widget information that meets a filter criterion on th
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| filter | formInfo.FormInfoFilter | Yes| Filter criterion.|
| filter | [formInfo.FormInfoFilter](./js-apis-formInfo.md#forminfofilter) | Yes| Filter criterion.|
| callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.|
**Example**
......@@ -214,7 +214,7 @@ Obtains the application's widget information on the device. This API uses a prom
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| filter | formInfo.FormInfoFilter | No| Filter criterion.|
| filter | [formInfo.FormInfoFilter](./js-apis-formInfo.md) | No| Filter criterion.|
**Return value**
......
......@@ -12,6 +12,10 @@
**Recommended use case**: Use **HashMap** when you need to quickly access, remove, and insert key-value pairs.
This topic uses the following to identify the use of generics:
- K: Key
- V: Value
## Modules to Import
```ts
......@@ -90,9 +94,9 @@ Checks whether this container contains the specified key.
```ts
let hashMap = new HashMap();
let result = hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
let result1 = hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
let result = hashMap.hasKey("squirrel");
hashMap.set("squirrel", 123);
let result1 = hashMap.hasKey("squirrel");
```
......@@ -121,7 +125,7 @@ Checks whether this container contains the specified value.
```ts
let hashMap = new HashMap();
let result = hashMap.hasValue(123);
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("squirrel", 123);
let result1 = hashMap.hasValue(123);
```
......@@ -150,9 +154,9 @@ Obtains the value of the specified key in this container.
```ts
let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356);
let result = hashMap.get("sdfs");
hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356);
let result = hashMap.get("sparrow");
```
......@@ -174,8 +178,8 @@ Adds all elements in a **HashMap** instance to this container.
```ts
let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356);
hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356);
let newHashMap = new HashMap();
hashMap.setAll(newHashMap);
```
......@@ -194,7 +198,7 @@ Adds an element to this container.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | K | Yes| Key of the target element.|
| value | V | Yes| Value of the element.|
| value | V | Yes| Value of the target element.|
**Return value**
......@@ -206,7 +210,7 @@ Adds an element to this container.
```ts
let hashMap = new HashMap();
let result = hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
let result = hashMap.set("squirrel", 123);
```
......@@ -234,9 +238,9 @@ Removes an element with the specified key from this container.
```ts
let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356);
let result = hashMap.remove("sdfs");
hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356);
let result = hashMap.remove("sparrow");
```
......@@ -252,8 +256,8 @@ Clears this container and sets its length to **0**.
```ts
let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356);
hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356);
hashMap.clear();
```
......@@ -276,8 +280,8 @@ Obtains an iterator that contains all the elements in this container.
```ts
let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356);
hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356);
let iter = hashMap.keys();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -305,8 +309,8 @@ Obtains an iterator that contains all the values in this container.
```ts
let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356);
hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356);
let iter = hashMap.values();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -341,8 +345,8 @@ Replaces an element in this container.
```ts
let hashMap = new HashMap();
hashMap.set("sdfs", 123);
let result = hashMap.replace("sdfs", 357);
hashMap.set("sparrow", 123);
let result = hashMap.replace("sparrow", 357);
```
......@@ -372,8 +376,8 @@ callbackfn
```ts
let hashMap = new HashMap();
hashMap.set("sdfs", 123);
hashMap.set("dfsghsf", 357);
hashMap.set("sparrow", 123);
hashMap.set("gull", 357);
hashMap.forEach((value, key) => {
console.log("value:" + value, key);
});
......@@ -398,8 +402,8 @@ Obtains an iterator that contains all the elements in this container.
```ts
let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356);
hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356);
let iter = hashMap.entries();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -427,8 +431,8 @@ Obtains an iterator, each item of which is a JavaScript object.
**Example**
```ts
let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356);
hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356);
// Method 1:
for (let item of hashMap) {
......
......@@ -10,6 +10,9 @@ Unlike [TreeSet](js-apis-treeset.md), which stores and accesses data in sorted o
**Recommended use case**: Use **HashSet** when you need a set that has only unique elements or need to deduplicate a set.
This topic uses the following to identify the use of generics:
- T: Type
## Modules to Import
```ts
......@@ -26,6 +29,17 @@ import HashSet from '@ohos.util.HashSet';
| -------- | -------- | -------- | -------- | -------- |
| length | number | Yes| No| Number of elements in a hash set (called container later).|
**Example**
```ts
let hashSet = new HashSet();
hashSet.add(1);
hashSet.add(2);
hashSet.add(3);
hashSet.add(4);
hashSet.add(5);
let res = hashSet.length;
```
### constructor
......@@ -88,9 +102,9 @@ Checks whether this container contains the specified element.
```ts
let hashSet = new HashSet();
let result = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
let result1 = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
let result = hashSet.has("squirrel");
hashSet.add("squirrel");
let result1 = hashSet.has("squirrel");
```
......@@ -118,7 +132,7 @@ Adds an element to this container.
```ts
let hashSet = new HashSet();
let result = hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
let result = hashSet.add("squirrel");
```
......@@ -146,9 +160,9 @@ Removes an element from this container.
```ts
let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs");
let result = hashSet.remove("sdfs");
hashSet.add("squirrel");
hashSet.add("sparrow");
let result = hashSet.remove("sparrow");
```
......@@ -164,8 +178,8 @@ Clears this container and sets its length to **0**.
```ts
let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs");
hashSet.add("squirrel");
hashSet.add("sparrow");
hashSet.clear();
```
......@@ -188,8 +202,8 @@ Obtains an iterator that contains all the values in this container.
```ts
let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs");
hashSet.add("squirrel");
hashSet.add("sparrow");
let iter = hashSet.values();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -225,8 +239,8 @@ callbackfn
```ts
let hashSet = new HashSet();
hashSet.add("sdfs");
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sparrow");
hashSet.add("squirrel");
hashSet.forEach((value, key) => {
console.log("value:" + value, key);
});
......@@ -250,8 +264,8 @@ Obtains an iterator that contains all the elements in this container.
```ts
let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs");
hashSet.add("squirrel");
hashSet.add("sparrow");
let iter = hashSet.entries();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -280,8 +294,8 @@ Obtains an iterator, each item of which is a JavaScript object.
```ts
let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs");
hashSet.add("squirrel");
hashSet.add("sparrow");
// Method 1:
for (let item of hashSet) {
......
......@@ -115,7 +115,7 @@ const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer).then(() => {
console.log('Succeeded in reading image pixel data.'); // Called if the condition is met.
}).catch(error => {
('Failed to read image pixel data.'); // Called if no condition is met.
console.log('Failed to read image pixel data.'); // Called if no condition is met.
})
```
......@@ -261,12 +261,7 @@ image.createPixelMap(color, opts)
}
pixelmap.writePixels(area).then(() => {
const readArea = { pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
// region.size.width + x < opts.width, region.size.height + y < opts.height
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
console.info('Succeeded to write pixelmap into the specified area.');
})
}).catch(error => {
console.log('error: ' + error);
......@@ -291,17 +286,20 @@ Writes image pixel map data to an area. This API uses an asynchronous callback t
**Example**
```js
const area = new ArrayBuffer(400);
const area = { pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
let bufferArr = new Uint8Array(area.pixels);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
pixelmap.writePixels(area, (error) => {
if (error != undefined) {
console.info('Failed to write pixelmap into the specified area.');
} else {
const readArea = {
pixels: new ArrayBuffer(20),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 },
}
console.info('Succeeded to write pixelmap into the specified area.');
}
})
```
......@@ -330,9 +328,11 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj
```js
const color = new ArrayBuffer(96);
const pixelMap = new ArrayBuffer(400);
let bufferArr = new Uint8Array(color);
pixelMap.writeBufferToPixels(color).then(() => {
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
pixelmap.writeBufferToPixels(color).then(() => {
console.log("Succeeded in writing data from a buffer to a PixelMap.");
}).catch((err) => {
console.error("Failed to write data from a buffer to a PixelMap.");
......@@ -358,9 +358,11 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj
```js
const color = new ArrayBuffer(96);
const pixelMap = new ArrayBuffer(400);
let bufferArr = new Uint8Array(color);
pixelMap.writeBufferToPixels(color, function(err) {
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
pixelmap.writeBufferToPixels(color, function(err) {
if (err) {
console.error("Failed to write data from a buffer to a PixelMap.");
return;
......@@ -387,12 +389,22 @@ Obtains pixel map information of this image. This API uses a promise to return t
**Example**
```js
const pixelMap = new ArrayBuffer(400);
pixelMap.getImageInfo().then(function(info) {
console.log("Succeeded in obtaining the image pixel map information.");
}).catch((err) => {
console.error("Failed to obtain the image pixel map information.");
});
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } }
image.createPixelMap(color, opts).then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.error("Failed to obtain the image pixel map information.");
}
pixelmap.getImageInfo().then(imageInfo => {
if (imageInfo == undefined) {
console.error("Failed to obtain the image pixel map information.");
}
if (imageInfo.size.height == 4 && imageInfo.size.width == 6) {
console.log("Succeeded in obtaining the image pixel map information.");
}
})
})
```
### getImageInfo<sup>7+</sup>
......@@ -412,8 +424,21 @@ Obtains pixel map information of this image. This API uses an asynchronous callb
**Example**
```js
pixelmap.getImageInfo((imageInfo) => {
console.log("Succeeded in obtaining the image pixel map information.");
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
if (pixelmap == undefined) {
globalpixelmap = pixelmap;
console.error("Failed to obtain the image pixel map information.");
}
pixelmap.getImageInfo((err, imageInfo) => {
if (imageInfo == undefined) {
console.error("Failed to obtain the image pixel map information.");
}
if (imageInfo.size.height == 4 && imageInfo.size.width == 6) {
console.log("Succeeded in obtaining the image pixel map information.");
}
})
})
```
......@@ -500,9 +525,15 @@ Sets an opacity rate for this image pixel map. This API uses an asynchronous cal
**Example**
```js
async function () {
await pixelMap.opacity(0.5);
}
var rate = 0.5;
pixelmap.opacity(rate, (err) => {
if (err) {
console.error("Failed to set opacity.");
return;
} else {
console.log("Succeeded in setting opacity.");
}
})
```
### opacity<sup>9+</sup>
......@@ -529,7 +560,8 @@ Sets an opacity rate for this image pixel map. This API uses a promise to return
```js
async function () {
await pixelMap.opacity(0.5);
var rate = 0.5;
await pixelmap.opacity(rate);
}
```
......@@ -550,12 +582,8 @@ Creates a **PixelMap** object that contains only the alpha channel information.
**Example**
```js
pixelMap.createAlphaPixelmap(async (err, alphaPixelMap) => {
if (alphaPixelMap == undefined) {
console.info('Failed to obtain new pixel map.');
} else {
console.info('Succeed in obtaining new pixel map.');
}
async function () {
await pixelmap.createAlphaPixelmap();
})
```
......@@ -576,14 +604,13 @@ Creates a **PixelMap** object that contains only the alpha channel information.
**Example**
```js
let pixelMap = await imageSource.createPixelMap();
if (pixelMap != undefined) {
pixelMap.createAlphaPixelmap(async (err, alphaPixelMap) => {
console.info('Failed to obtain new pixel map.');
})
} else {
console.info('Succeed in obtaining new pixel map.');
}
pixelmap.createAlphaPixelmap((err, alphaPixelMap) => {
if (alphaPixelMap == undefined) {
console.info('Failed to obtain new pixel map.');
} else {
console.info('Succeed in obtaining new pixel map.');
}
})
```
### scale<sup>9+</sup>
......@@ -606,7 +633,7 @@ Scales this image based on the input width and height. This API uses an asynchro
```js
async function () {
await pixelMap.scale(2.0, 1.0);
await pixelmap.scale(2.0, 1.0);
}
```
......@@ -635,7 +662,7 @@ Scales this image based on the input width and height. This API uses a promise t
```js
async function () {
await pixelMap.scale(2.0, 1.0);
await pixelmap.scale(2.0, 1.0);
}
```
......@@ -659,7 +686,7 @@ Translates this image based on the input coordinates. This API uses an asynchron
```js
async function () {
await pixelMap.translate(3.0, 1.0);
await pixelmap.translate(3.0, 1.0);
}
```
......@@ -688,7 +715,7 @@ Translates this image based on the input coordinates. This API uses a promise to
```js
async function () {
await pixelMap.translate(3.0, 1.0);
await pixelmap.translate(3.0, 1.0);
}
```
......@@ -711,7 +738,7 @@ Rotates this image based on the input angle. This API uses an asynchronous callb
```js
async function () {
await pixelMap.rotate(90.0);
await pixelmap.rotate(90.0);
}
```
......@@ -739,7 +766,7 @@ Rotates this image based on the input angle. This API uses a promise to return t
```js
async function () {
await pixelMap.rotate(90.0);
await pixelmap.rotate(90.0);
}
```
......@@ -763,7 +790,7 @@ Flips this image horizontally or vertically, or both. This API uses an asynchron
```js
async function () {
await pixelMap.flip(false, true);
await pixelmap.flip(false, true);
}
```
......@@ -792,7 +819,7 @@ Flips this image horizontally or vertically, or both. This API uses a promise to
```js
async function () {
await pixelMap.flip(false, true);
await pixelmap.flip(false, true);
}
```
......@@ -815,7 +842,7 @@ Crops this image based on the input size. This API uses an asynchronous callback
```js
async function () {
await pixelMap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } });
await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } });
}
```
......@@ -843,7 +870,7 @@ Crops this image based on the input size. This API uses a promise to return the
```js
async function () {
await pixelMap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } });
await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } });
}
```
......@@ -954,7 +981,8 @@ Creates an **ImageSource** instance based on the URI.
**Example**
```js
const imageSourceApi = image.createImageSource('/sdcard/test.jpg');
var sourceOptions = { sourceDensity: 120 };
let imageSource = image.createImageSource('test.png', sourceOptions);
```
## image.createImageSource<sup>7+</sup>
......@@ -1007,7 +1035,8 @@ Creates an **ImageSource** instance based on the file descriptor.
**Example**
```js
const imageSourceApi = image.createImageSource(fd);
var sourceOptions = { sourceDensity: 120 };
const imageSourceApi = image.createImageSource(0, sourceOptions);
```
## image.createImageSource<sup>9+</sup>
......@@ -1059,9 +1088,9 @@ const data = new ArrayBuffer(112);
const imageSourceApi = image.createImageSource(data);
```
## image.CreateIncrementalSource<sup>9+</sup>
## image.createIncrementalSource<sup>9+</sup>
CreateIncrementalSource(buf: ArrayBuffer): ImageSource
createIncrementalSource(buf: ArrayBuffer): ImageSource
Creates an **ImageSource** instance in incremental mode based on the buffers.
......@@ -1083,12 +1112,12 @@ Creates an **ImageSource** instance in incremental mode based on the buffers.
```js
const buf = new ArrayBuffer(96);
const imageSourceApi = image.CreateIncrementalSource(buf);
const imageSourceIncrementalSApi = image.createIncrementalSource(buf);
```
## image.CreateIncrementalSource<sup>9+</sup>
## image.createIncrementalSource<sup>9+</sup>
CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource
createIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource
Creates an **ImageSource** instance in incremental mode based on the buffers.
......@@ -1111,7 +1140,7 @@ Creates an **ImageSource** instance in incremental mode based on the buffers.
```js
const buf = new ArrayBuffer(96);
const imageSourceApi = image.CreateIncrementalSource(buf);
const imageSourceIncrementalSApi = image.createIncrementalSource(buf);
```
## ImageSource
......@@ -1124,7 +1153,7 @@ Provides APIs to obtain image information. Before calling any API in **ImageSour
| Name | Type | Readable| Writable| Description |
| ---------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
| supportedFormats | Array\<string> | Yes | No | Supported image formats, including png, jpeg, wbmp, bmp, gif, webp, and heif.|
| supportedFormats | Array\<string> | Yes | No | Supported image formats, including PNG, JPEG, BMP, GIF, WebP, and RAW.|
### getImageInfo
......@@ -1282,7 +1311,7 @@ Obtains the value of a property in this image. This API uses an asynchronous cal
**Example**
```js
const property = new ArrayBuffer(400);
let property = { index: 0, defaultValue: '9999' }
imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => {
if(error) {
console.log('Failed to get the value of the specified attribute key of the image.');
......@@ -1477,7 +1506,15 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
**Example**
```js
const decodingOptions = new ArrayBuffer(400);
let decodingOptions = {
sampleSize: 1,
editable: true,
desiredSize: { width: 1, height: 2 },
rotate: 10,
desiredPixelFormat: 3,
desiredRegion: { size: { height: 1, width: 2 }, x: 0, y: 0 },
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, pixelmap => {
console.log('Succeeded in creating pixelmap object.');
})
......@@ -1551,7 +1588,7 @@ const imagePackerApi = image.createImagePacker();
## ImagePacker
Provide APIs to pack images. Before calling any API in **ImagePacker**, you must use **createImagePacker** to create an **ImagePacker** instance.
Provides APIs to pack images. Before calling any API in **ImagePacker**, you must use **createImagePacker** to create an **ImagePacker** instance. The image formats JPEG and WebP are supported.
### Attributes
......@@ -1581,7 +1618,6 @@ Packs an image. This API uses an asynchronous callback to return the result.
```js
let packOpts = { format:"image/jpeg", quality:98 };
const imageSourceApi = new ArrayBuffer(400);
imagePackerApi.packing(imageSourceApi, packOpts, data => {})
```
......@@ -1610,7 +1646,6 @@ Packs an image. This API uses a promise to return the result.
```js
let packOpts = { format:"image/jpeg", quality:98 }
const imageSourceApi = new ArrayBuffer(400);
imagePackerApi.packing(imageSourceApi, packOpts)
.then( data => {
console.log('packing succeeded.');
......@@ -2112,7 +2147,7 @@ Describes area information in an image.
| ------ | ------------------ | ---- | ---- | ------------------------------------------------------------ |
| pixels | ArrayBuffer | Yes | No | Pixels of the image. |
| offset | number | Yes | No | Offset for data reading. |
| stride | number | Yes | No | Number of bytes from one row of pixels in memory to the next row of pixels in memory. The value of **stride** must be greater than or equal to the value of **region.size.width** multiplied by 4. |
| stride | number | Yes | No | Number of bytes from one row of pixels in memory to the next row of pixels in memory. The value of **stride** must be greater than or equal to the value of **region.size.width** multiplied by 4. |
| region | [Region](#region7) | Yes | No | Region to read or write. The width of the region to write plus the X coordinate cannot be greater than the width of the original image. The height of the region to write plus the Y coordinate cannot be greater than the height of the original image.|
## ImageInfo
......@@ -2146,8 +2181,8 @@ Enumerates the pixel formats of images.
| ---------------------- | ------ | ----------------- |
| UNKNOWN | 0 | Unknown format. |
| RGB_565 | 2 | RGB_565. |
| RGBA_8888 | 3 | RGBA_8888.|
| BGRA_8888<sup>9+</sup> | 4 | BGRA_8888.|
| RGBA_8888 | 3 | RGBA_8888. |
| BGRA_8888<sup>9+</sup> | 4 | BGRA_8888. |
## AlphaType<sup>9+</sup>
......@@ -2159,8 +2194,8 @@ Enumerates the alpha types of images.
| -------- | ------ | ----------------------- |
| UNKNOWN | 0 | Unknown alpha type. |
| OPAQUE | 1 | There is no alpha or the image is opaque.|
| PREMUL | 2 | Premultiplied alpha. |
| UNPREMUL | 3 | Unpremultiplied alpha, that is, straight alpha. |
| PREMUL | 2 | Premultiplied alpha. |
| UNPREMUL | 3 | Unpremultiplied alpha, that is, straight alpha. |
## ScaleMode<sup>9+</sup>
......@@ -2236,7 +2271,7 @@ Defines the option for image packing.
| Name | Type | Readable| Writable| Description |
| ------- | ------ | ---- | ---- | --------------------------------------------------- |
| format | string | Yes | Yes | Format of the packed image.<br>Currently, the following raw formats are supported: .jpg, .png, .gif, .bmp, and .webp. |
| format | string | Yes | Yes | Format of the packed image.<br>Currently, the JPEG and WebP formats are supported. |
| quality | number | Yes | Yes | Quality of the output image during JPEG encoding. The value ranges from 1 to 100.|
## GetImagePropertyOptions<sup>7+</sup>
......
......@@ -12,6 +12,10 @@ Compared with **[HashMap](js-apis-hashmap.md)**, which can also store KV pairs,
**Recommended use case**: Use LightWeightMap when you need to store and access **KV pairs**.
This topic uses the following to identify the use of generics:
- K: Key
- V: Value
## Modules to Import
```ts
......@@ -92,10 +96,10 @@ Checks whether this container contains all elements of the specified **LightWeig
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let map = new LightWeightMap();
map.set("sdfs", 356);
map.set("sparrow", 356);
let result = lightWeightMap.hasAll(map);
```
......@@ -125,9 +129,9 @@ Checks whether this container contains the specified key.
```ts
let lightWeightMap = new LightWeightMap();
let result = lightWeightMap.hasKey;
lightWeightMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
let result1 = lightWeightMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightMap.hasKey("squirrel");
lightWeightMap.set("squirrel", 123);
let result1 = lightWeightMap.hasKey("squirrel");
```
......@@ -156,7 +160,7 @@ Checks whether this container contains the specified value.
```ts
let lightWeightMap = new LightWeightMap();
let result = lightWeightMap.hasValue(123);
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("squirrel", 123);
let result1 = lightWeightMap.hasValue(123);
```
......@@ -207,9 +211,9 @@ Obtains the value of the specified key in this container.
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
let result = lightWeightMap.get("sdfs");
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.get("sparrow");
```
......@@ -237,9 +241,9 @@ Obtains the index of the first occurrence of an element with the specified key i
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
let result = lightWeightMap.getIndexOfKey("sdfs");
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.getIndexOfKey("sparrow");
```
......@@ -267,8 +271,8 @@ Obtains the index of the first occurrence of an element with the specified value
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.getIndexOfValue(123);
```
......@@ -297,8 +301,8 @@ Obtains the key of an element at the specified position in this container.
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.getKeyAt(1);
```
......@@ -321,8 +325,8 @@ Adds all elements in a **LightWeightMap** instance to this container.
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let map = new LightWeightMap();
lightWeightMap.setAll(map);
```
......@@ -352,7 +356,7 @@ Adds an element to this container.
```ts
let lightWeightMap = new LightWeightMap();
let result = lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
let result = lightWeightMap.set("squirrel", 123);
```
......@@ -380,9 +384,9 @@ Removes an element with the specified key from this container.
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.remove("sdfs");
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
lightWeightMap.remove("sparrow");
```
......@@ -410,8 +414,8 @@ Removes an element at the specified position from this container.
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.removeAt(1);
```
......@@ -441,8 +445,8 @@ Sets a value for an element at the specified position in this container.
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
lightWeightMap.setValueAt(1, 3546);
```
......@@ -471,8 +475,8 @@ Obtains the value of an element at the specified position in this container.
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.getValueAt(1);
```
......@@ -489,8 +493,8 @@ Clears this container and sets its length to **0**.
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
lightWeightMap.clear();
```
......@@ -513,8 +517,8 @@ Obtains an iterator that contains all the keys in this container.
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let iter = lightWeightMap.keys();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -542,8 +546,8 @@ Obtains an iterator that contains all the values in this container.
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let iter = lightWeightMap.values();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -579,8 +583,8 @@ callbackfn
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("sdfs", 123);
lightWeightMap.set("dfsghsf", 357);
lightWeightMap.set("sparrow", 123);
lightWeightMap.set("gull", 357);
lightWeightMap.forEach((value, key) => {
console.log("value:" + value, key);
});
......@@ -605,8 +609,8 @@ Obtains an iterator that contains all the elements in this container.
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let iter = lightWeightMap.entries();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -634,8 +638,8 @@ Concatenates the elements in this container into a string and returns the string
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("A", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let iter = lightWeightMap.toString();
```
......@@ -657,8 +661,8 @@ Obtains an iterator, each item of which is a JavaScript object.
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356);
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
// Method 1:
for (let item of lightWeightMap) {
......
......@@ -14,6 +14,9 @@ Compared with **[HashSet](js-apis-hashset.md)**, which can also store values, **
**Recommended use case**: Use **LightWeightSet** when you need a set that has only unique elements or need to deduplicate a set.
This topic uses the following to identify the use of generics:
- T: Type
## Modules to Import
```ts
......@@ -93,7 +96,7 @@ Adds an element to this container.
```ts
let lightWeightSet = new LightWeightSet();
let result = lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
let result = lightWeightSet.add("squirrel");
```
......@@ -115,10 +118,10 @@ Adds all elements in a **LightWeightSet** instance to this container.
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let set = new LightWeightSet();
set.add("sfage");
set.add("gull");
let result = lightWeightSet.addAll(set);
```
......@@ -147,10 +150,10 @@ Checks whether this container contains all elements of the specified **LightWeig
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let set = new LightWeightSet();
set.add("sdfs");
set.add("sparrow");
let result = lightWeightSet.hasAll(set);
```
......@@ -209,9 +212,9 @@ Checks whether this container contains objects of the same type as the specified
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
let obj = ["Ahfbrgrbgnutfodgorrogorgrogofdfdf", "sdfs"];
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let obj = ["squirrel", "sparrow"];
let result = lightWeightSet.equal(obj);
```
......@@ -262,9 +265,9 @@ Obtains the position index of the element with the specified key in this contain
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
let result = lightWeightSet.getIndexOf("sdfs");
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let result = lightWeightSet.getIndexOf("sparrow");
```
......@@ -292,9 +295,9 @@ Removes an element of the specified key from this container.
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
let result = lightWeightSet.remove("sdfs");
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let result = lightWeightSet.remove("sparrow");
```
......@@ -322,8 +325,8 @@ Removes the element at the specified position from this container.
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let result = lightWeightSet.removeAt(1);
```
......@@ -352,8 +355,8 @@ Obtains the value of the element at the specified position in this container.
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let result = lightWeightSet.getValueAt(1);
```
......@@ -370,8 +373,8 @@ Clears this container and sets its length to **0**.
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
lightWeightSet.clear();
```
......@@ -394,8 +397,8 @@ Obtains a string that contains all elements in this container.
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let result = lightWeightSet.toString();
```
......@@ -418,8 +421,8 @@ Obtains an array that contains all objects in this container.
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let result = lightWeightSet.toArray();
```
......@@ -442,8 +445,8 @@ Obtains an iterator that contains all the values in this container.
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let iter = lightWeightSet.values();
let index = 0;
while(index < lightWeightSet.length) {
......@@ -479,8 +482,8 @@ callbackfn
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("sdfs");
lightWeightSet.add("dfsghsf");
lightWeightSet.add("sparrow");
lightWeightSet.add("gull");
lightWeightSet.forEach((value, key) => {
console.log("value:" + value, key);
});
......@@ -505,8 +508,8 @@ Obtains an iterator that contains all the elements in this container.
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let iter = lightWeightSet.entries();
let index = 0;
while(index < lightWeightSet.length) {
......@@ -534,8 +537,8 @@ Obtains an iterator, each item of which is a JavaScript object.
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs");
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
// Method 1:
for (let item of lightWeightSet) {
......
......@@ -12,6 +12,9 @@ Unlike **[List](js-apis-list.md)**, which is a singly linked list, **LinkedList*
**Recommended use case**: Use **LinkedList** for frequent insertion and removal operations.
This topic uses the following to identify the use of generics:
- T: Type
## Modules to Import
```ts
......@@ -76,7 +79,7 @@ let result = linkedList.add("a");
let result1 = linkedList.add(1);
let b = [1, 2, 3];
linkedList.add(b);
let c = {name : "lala", age : "13"};
let c = {name : "Dylon", age : "13"};
let result3 = linkedList.add(false);
```
......@@ -102,7 +105,7 @@ linkedList.addFirst("a");
linkedList.addFirst(1);
let b = [1, 2, 3];
linkedList.addFirst(b);
let c = {name : "lala", age : "13"};
let c = {name : "Dylon", age : "13"};
linkedList.addFirst(false);
```
......@@ -154,9 +157,9 @@ Checks whether this container has the specified element.
```ts
let linkedList = new LinkedList();
let result1 = linkedList.has("Ahfbrgrbgnutfodgorrogorg");
linkedList.add("Ahfbrgrbgnutfodgorrogorg");
let result = linkedList.has("Ahfbrgrbgnutfodgorrogorg");
let result1 = linkedList.has("squirrel");
linkedList.add("squirrel");
let result = linkedList.has("squirrel");
```
### get
......
......@@ -10,6 +10,9 @@ Unlike [LinkedList](js-apis-linkedlist.md), which is a doubly linked list, **Lis
**Recommended use case**: Use **List** for frequent insertion and removal operations.
This topic uses the following to identify the use of generics:
- T: Type
## Modules to Import
```ts
......@@ -72,7 +75,7 @@ let result = list.add("a");
let result1 = list.add(1);
let b = [1, 2, 3];
list.add(b);
let c = {name : "lala", age : "13"};
let c = {name : "Dylon", age : "13"};
let result3 = list.add(false);
```
......@@ -124,9 +127,9 @@ Checks whether this container has the specified element.
```ts
let list = new List();
let result = list.has("Ahfbrgrbgnutfodgorrogorg");
list.add("Ahfbrgrbgnutfodgorrogorg");
let result1 = list.has("Ahfbrgrbgnutfodgorrogorg");
let result = list.has("squirrel");
list.add("squirrel");
let result1 = list.has("squirrel");
```
### get
......@@ -181,7 +184,7 @@ Obtains the index of the last occurrence of the specified element in this contai
| Value Type | Description|
| -------- | -------- |
| number | Returns the position index if obtained; returns **-1** otherwise.|
| number | Returns the index if obtained; returns **-1** otherwise.|
**Example**
......@@ -265,7 +268,7 @@ obj1.add(2);
obj1.add(4);
obj1.add(5);
list.equal(obj1);
let obj2 = {name : "lala", age : "13"};
let obj2 = {name : "Dylon", age : "13"};
let result = list.equal(obj2);
```
......
......@@ -53,7 +53,7 @@ Creates a **VideoPlayer** instance. This API uses an asynchronous callback to re
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ------------------------------ |
| callback | AsyncCallback<[VideoPlayer](#videoplayer8)> | Yes | Callback used to return the **VideoPlayer** instance created.|
| callback | AsyncCallback<[VideoPlayer](#videoplayer8)> | Yes | Callback used to return the **VideoPlayer** instance, which can be used to manage and play video media.|
**Example**
......@@ -82,7 +82,7 @@ Creates a **VideoPlayer** instance. This API uses a promise to return the result
| Type | Description |
| ------------------------------------- | ----------------------------------- |
| Promise<[VideoPlayer](#videoplayer8)> | Promise used to return the **VideoPlayer** instance created.|
| Promise<[VideoPlayer](#videoplayer8)> | Promise used to return the **VideoPlayer** instance, which can be used to manage and play video media.|
**Example**
......@@ -135,7 +135,7 @@ Only one **AudioRecorder** instance can be created per device.
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------ |
| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | Yes | Callback used to return the **VideoRecorder** instance created.|
| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | Yes | Callback used to return the **VideoRecorder** instance, which can be used to record video media.|
**Example**
......@@ -165,7 +165,7 @@ Only one **AudioRecorder** instance can be created per device.
| Type | Description |
| ----------------------------------------- | ----------------------------------- |
| Promise<[VideoRecorder](#videorecorder9)> | Promise used to return the **VideoRecorder** instance created.|
| Promise<[VideoRecorder](#videorecorder9)> | Promise used to return the **VideoRecorder** instance, which can be used to record video media.|
**Example**
......@@ -275,15 +275,15 @@ For details about the audio playback demo, see [Audio Playback Development](../.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
| Name | Type | Readable| Writable| Description |
| ------------------------------- | ----------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| src | string | Yes | Yes | Audio file URI. The mainstream audio formats (M4A, AAC, MPEG-3, OGG, and WAV) are supported.<br>**Examples of supported URI schemes**:<br>1. FD: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP: http://xx<br>3. HTTPS: https://xx<br>4. HLS: http://xx or https://xx<br>**Required permissions**: ohos.permission.INTERNET|
| fdSrc<sup>9+</sup> | [AVFileDescriptor](#avfiledescriptor9) | Yes | Yes | Description of the audio file. This attribute is required when audio resources of an application are continuously stored in a file.<br>**Example:**<br>Assume that a music file that stores continuous music resources consists of the following:<br>Music 1 (address offset: 0, byte length: 100)<br>Music 2 (address offset: 101; byte length: 50)<br>Music 3 (address offset: 151, byte length: 150)<br>1. To play music 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }<br>2. To play music 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }<br>3. To play music 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }<br>If the file is an independent music file, use **src=fd://xx**.<br>|
| loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. |
| audioInterruptMode<sup>9+</sup> | [audio.InterruptMode](js-apis-audio.md#interruptmode9) | Yes | Yes | Audio interruption mode. |
| currentTime | number | Yes | No | Current audio playback position, in ms. |
| duration | number | Yes | No | Audio duration, in ms. |
| state | [AudioState](#audiostate) | Yes | No | Audio playback state. This state cannot be used as the condition for triggering the call of **play()**, **pause()**, or **stop()**.|
| Name | Type | Readable| Writable| Description |
| ------------------------------- | ------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| src | string | Yes | Yes | Audio file URI. The mainstream audio formats (M4A, AAC, MPEG-3, OGG, and WAV) are supported.<br>**Examples of supported URI schemes**:<br>1. FD: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP: http://xx<br>3. HTTPS: https://xx<br>4. HLS: http://xx or https://xx<br>**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.INTERNET|
| fdSrc<sup>9+</sup> | [AVFileDescriptor](#avfiledescriptor9) | Yes | Yes | Description of the audio file. This attribute is required when audio resources of an application are continuously stored in a file.<br>**Example:**<br>Assume that a music file that stores continuous music resources consists of the following:<br>Music 1 (address offset: 0, byte length: 100)<br>Music 2 (address offset: 101; byte length: 50)<br>Music 3 (address offset: 151, byte length: 150)<br>1. To play music 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }<br>2. To play music 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }<br>3. To play music 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }<br>If the file is an independent music file, use **src=fd://xx**.<br>|
| loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. |
| audioInterruptMode<sup>9+</sup> | [audio.InterruptMode](js-apis-audio.md#interruptmode9) | Yes | Yes | Audio interruption mode. |
| currentTime | number | Yes | No | Current audio playback position, in ms. |
| duration | number | Yes | No | Audio duration, in ms. |
| state | [AudioState](#audiostate) | Yes | No | Audio playback state. This state cannot be used as the condition for triggering the call of **play()**, **pause()**, or **stop()**.|
### play<a name=audioplayer_play></a>
play(): void
......@@ -442,7 +442,7 @@ function printfDescription(obj) {
}
}
audioPlayer.getTrackDescription((error, ) => {
audioPlayer.getTrackDescription((error, arrlist) => {
if (arrlist != null) {
for (let i = 0; i < arrlist.length; i++) {
printfDescription(arrlist[i]);
......@@ -680,7 +680,7 @@ For details about the video playback demo, see [Video Playback Development](../.
| Name | Type | Readable| Writable| Description |
| ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| url<sup>8+</sup> | string | Yes | Yes | Video media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.<br>**Example of supported URIs**:<br>1. FD: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP: http://xx<br>3. HTTPS: https://xx<br>4. HLS: http://xx or https://xx<br>**Required permissions**: ohos.permission.INTERNET|
| url<sup>8+</sup> | string | Yes | Yes | Video media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.<br>**Example of supported URIs**:<br>1. FD: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP: http://xx<br>3. HTTPS: https://xx<br>4. HLS: http://xx or https://xx<br>|
| fdSrc<sup>9+</sup> | [AVFileDescriptor](#avfiledescriptor9) | Yes| Yes| Description of a video file. This attribute is required when video resources of an application are continuously stored in a file.<br>**Example:**<br>Assume that a music file that stores continuous music resources consists of the following:<br>Video 1 (address offset: 0, byte length: 100)<br>Video 2 (address offset: 101; byte length: 50)<br>Video 3 (address offset: 151, byte length: 150)<br>1. To play video 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }<br>2. To play video 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }<br>3. To play video 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }<br>To play an independent video file, use **src=fd://xx**.<br>|
| loop<sup>8+</sup> | boolean | Yes | Yes | Whether to loop video playback. The value **true** means to loop video playback, and **false** means the opposite. |
| videoScaleType<sup>9+</sup> | [VideoScaleType](#videoscaletype9) | Yes | Yes | Video scale type. |
......@@ -1795,7 +1795,7 @@ Subscribes to the audio recording events.
```js
let audioRecorder = media.createAudioRecorder(); // Create an AudioRecorder instance.
let audioRecorderConfig = {
audioEncoder : media.AudioEncoder.AAC_LC, ,
audioEncoder : media.AudioEncoder.AAC_LC,
audioEncodeBitRate : 22050,
audioSampleRate : 22050,
numberOfChannels : 2,
......@@ -1850,7 +1850,7 @@ Subscribes to audio recording error events. After an error event is reported, yo
```js
let audioRecorderConfig = {
audioEncoder : media.AudioEncoder.AAC_LC, ,
audioEncoder : media.AudioEncoder.AAC_LC,
audioEncodeBitRate : 22050,
audioSampleRate : 22050,
numberOfChannels : 2,
......@@ -1974,29 +1974,13 @@ let videoConfig = {
}
// asyncallback
let videoRecorder = null;
let events = require('events');
let eventEmitter = new events.EventEmitter();
eventEmitter.on('prepare', () => {
videoRecorder.prepare(videoConfig, (err) => {
if (err == null) {
console.info('prepare success');
} else {
console.info('prepare failed and error is ' + err.message);
}
});
});
media.createVideoRecorder((err, recorder) => {
if (err == null && recorder != null) {
videoRecorder = recorder;
console.info('createVideoRecorder success');
eventEmitter.emit('prepare'); // Trigger the 'prepare' event.
videoRecorder.prepare(videoConfig, (err) => {
if (err == null) {
console.info('prepare success');
} else {
console.info('createVideoRecorder failed and error is ' + err.message);
console.info('prepare failed and error is ' + err.message);
}
});
})
```
### prepare<sup>9+</sup><a name=videorecorder_prepare2></a>
......@@ -2047,21 +2031,10 @@ let videoConfig = {
}
// promise
let videoRecorder = null;
media.createVideoRecorder().then((recorder) => {
if (recorder != null) {
videoRecorder = recorder;
console.info('createVideoRecorder success');
videoRecorder.prepare(videoConfig).then(() => {
console.info('prepare success');
}).catch((err) => {
console.info('prepare failed and catch error is ' + err.message);
});
} else {
console.info('createVideoRecorder failed');
}
videoRecorder.prepare(videoConfig).then(() => {
console.info('prepare success');
}).catch((err) => {
console.info('catch err error message is ' + err.message);
console.info('prepare failed and catch error is ' + err.message);
});
```
......@@ -2475,11 +2448,10 @@ Subscribes to video recording error events. After an error event is reported, yo
**Example**
```js
// This event is reported when an error occurs during the retrieval of videoRecordState.
videoRecorder.on('error', (error) => { // Set the 'error' event callback.
console.info(`audio error called, error: ${error}`);
}
// This event is reported when an error occurs during the retrieval of videoRecordState.
});
})
```
## VideoRecordState<sup>9+</sup>
......
......@@ -12,6 +12,9 @@ Both **PlainArray** and **[LightWeightMap](js-apis-lightweightmap.md)** are used
**Recommended use case**: Use **PlainArray** when you need to store KV pairs whose keys are of the **number** type.
This topic uses the following to identify the use of generics:
- T: Type
## Modules to Import
```ts
......@@ -93,7 +96,7 @@ Checks whether this container contains the specified key.
```ts
let plainArray = new PlainArray();
plainArray.has(1);
plainArray.add(1, "sddfhf");
plainArray.add(1, "squirrel");
let result1 = plainArray.has(1);
```
......@@ -122,8 +125,8 @@ Obtains the value of the specified key in this container.
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.get(1);
```
......@@ -152,8 +155,8 @@ Obtains the index of the first occurrence of an element with the specified key i
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.getIndexOfKey(2);
```
......@@ -182,9 +185,9 @@ Obtains the index of the first occurrence of an element with the specified value
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
let result = plainArray.getIndexOfValue("sddfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.getIndexOfValue("squirrel");
```
......@@ -212,8 +215,8 @@ Obtains the key of the element at the specified position in this container.
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.getKeyAt(1);
```
......@@ -241,8 +244,8 @@ Obtains the value of an element at the specified position in this container.
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.getKeyAt(1);
```
......@@ -264,8 +267,8 @@ Clones this container and returns a copy. The modification to the copy does not
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let newPlainArray = plainArray.clone();
```
......@@ -289,7 +292,7 @@ Adds an element to this container.
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(1, "squirrel");
```
......@@ -317,8 +320,8 @@ Removes an element with the specified key from this container.
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
plainArray.remove(2);
let result = plainArray.remove(2);
```
......@@ -348,8 +351,8 @@ Removes an element at the specified position from this container.
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
plainArray.removeAt(1);
let result = plainArray.removeAt(1);
```
......@@ -380,8 +383,8 @@ Removes elements in a specified range from this container.
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.removeRangeFrom(1, 3);
```
......@@ -405,8 +408,8 @@ Sets a value for an element at the specified position in this container.
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
plainArray.setValueAt(1, 3546);
```
......@@ -429,8 +432,8 @@ Obtains a string that contains all elements in this container.
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.toString();
```
......@@ -447,8 +450,8 @@ Clears this container and sets its length to **0**.
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
plainArray.clear();
```
......@@ -479,8 +482,8 @@ callbackfn
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
plainArray.forEach((value, index) => {
console.log("value:" + value, index);
});
......@@ -505,8 +508,8 @@ Obtains an iterator object that contains key-value pairs, where the key is of th
```ts
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
// Method 1:
for (let item of plainArray) {
......
# ProcessRunningInfo
# ProcessRunningInfo<sup>(deprecated)</sup>
The **ProcessRunningInfo** module provides process running information.
> **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 APIs provided by this module are deprecated since API version 9. You are advised to use [ProcessRunningInformation<sup>9+</sup>](js-apis-processrunninginformation.md) instead.
> - The initial APIs of this module are supported since API version 8.
## Usage
......@@ -19,9 +19,9 @@ appManager.getProcessRunningInfos((error,data) => {
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID.|
......
# ProcessRunningInformation<sup>9+</sup>
The **ProcessRunningInformation** module provides process running information.
> **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.
## Usage Guidelines
The process running information is obtained through [appManager](js-apis-appmanager.md#appmanagergetprocessrunninginformation9).
```js
import appManager from '@ohos.application.appManager';
appManager.getProcessRunningInformation((error,data) => {
console.log("getProcessRunningInformation error: " + error.code + " data: " + JSON.stringify(data));
});
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID.|
| processName | string | Yes| No| Process name.|
| bundleNames | Array&lt;string&gt; | Yes| No| Names of all running bundles in the process.|
......@@ -10,6 +10,9 @@ Unlike **[Deque](js-apis-deque.md)**, which supports insertion and removal at bo
**Recommended use case**: Use **Queue** in FIFO scenarios.
This topic uses the following to identify the use of generics:
- T: Type
## Modules to Import
```ts
......@@ -72,7 +75,7 @@ let result1 = queue.add(1);
queue.add(1);
let b = [1, 2, 3];
queue.add(b);
let c = {name : "lala", age : "13"};
let c = {name : "Dylon", age : "13"};
let result3 = queue.add(c);
```
......@@ -180,6 +183,7 @@ Obtains an iterator, each item of which is a JavaScript object.
| IterableIterator&lt;T&gt; | Iterator obtained.|
**Example**
```ts
let queue = new Queue();
queue.add(2);
......
......@@ -55,7 +55,7 @@ Describes the size of the screen region to capture.
## screenshot.save
save(options?: ScreenshotOptions, callback: AsyncCallback&lt;image.PixelMap&gt;): void
save(options: ScreenshotOptions, callback: AsyncCallback&lt;image.PixelMap&gt;): void
Takes a screenshot and saves it as a **PixelMap** object. This API uses an asynchronous callback to return the result.
......@@ -67,7 +67,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses an async
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot settings consist of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set the parameters separately.|
| options | [ScreenshotOptions](#screenshotoptions) | Yes | Screenshot settings consist of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set the parameters separately.|
| callback | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Yes | Callback used to return a **PixelMap** object. |
**Example**
......@@ -97,6 +97,35 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses an async
## screenshot.save
save(callback: AsyncCallback&lt;image.PixelMap&gt;): void
Takes a screenshot and saves it as a **PixelMap** object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Required permissions**: ohos.permission.CAPTURE_SCREEN (available only to system applications)
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Yes | Callback used to return a **PixelMap** object. |
**Example**
```js
screenshot.save((err, pixelMap) => {
if (err) {
console.log('Failed to save screenshot: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
pixelMap.release(); // Release the memory in time after the PixelMap is used.
});
```
## screenshot.save
save(options?: ScreenshotOptions): Promise&lt;image.PixelMap&gt;
Takes a screenshot and saves it as a **PixelMap** object. This API uses a promise to return the result.
......
......@@ -10,6 +10,9 @@ Unlike **[Queue](js-apis-queue.md)**, which is implemented based on the queue da
**Recommended use case**: Use **Stack** in LOFI scenarios.
This topic uses the following to identify the use of generics:
- T: Type
## Modules to Import
```ts
......@@ -73,7 +76,7 @@ let result = stack.push("a");
let result1 = stack.push(1);
let b = [1, 2, 3];
stack.push(b);
let c = {name : "lala", age : "13"};
let c = {name : "Dylon", age : "13"};
let result3 = stack.push(c);
```
......
......@@ -29,7 +29,7 @@ export default class UserTestRunner implements TestRunner {
onPrepare() {
console.log("Trigger onPrepare")
}
onRun(){}
onRun(){}
};
```
......@@ -50,6 +50,6 @@ export default class UserTestRunner implements TestRunner {
onPrepare() {
console.log("Trigger onRun")
}
onRun(){}
onRun(){}
};
```
......@@ -12,6 +12,10 @@
Recommended use case: Use **TreeMap** when you need to store KV pairs in sorted order.
This topic uses the following to identify the use of generics:
- K: Key
- V: Value
## Modules to Import
```ts
......@@ -96,9 +100,9 @@ Checks whether this container has the specified key.
```ts
let treeMap = new TreeMap();
let result = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
let result1 = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
let result = treeMap.hasKey("squirrel");
treeMap.set("squirrel", 123);
let result1 = treeMap.hasKey("squirrel");
```
......@@ -127,7 +131,7 @@ Checks whether this container has the specified value.
```ts
let treeMap = new TreeMap();
let result = treeMap.hasValue(123);
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("squirrel", 123);
let result1 = treeMap.hasValue(123);
```
......@@ -156,9 +160,9 @@ Obtains the value of the specified key in this container.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356);
let result = treeMap.get("sdfs");
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
let result = treeMap.get("sparrow");
```
......@@ -180,8 +184,8 @@ Obtains the first key in this container.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356);
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
let result = treeMap.getFirstKey();
```
......@@ -204,8 +208,8 @@ Obtains the last key in this container.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356);
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
let result = treeMap.getLastKey();
```
......@@ -228,8 +232,8 @@ Adds all elements in a **TreeMap** instance to this container.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356);
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
let map = new TreeMap();
treeMap.setAll(map);
```
......@@ -260,7 +264,7 @@ Adds an element to this container.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("squirrel", 123);
```
......@@ -288,9 +292,9 @@ Removes the element with the specified key from this container.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356);
treeMap.remove("sdfs");
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
treeMap.remove("sparrow");
```
......@@ -318,10 +322,10 @@ Obtains the key that is placed in front of the input key in this container.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356);
treeMap.set("zdfgsd", 356);
let result = treeMap.getLowerKey("sdfs");
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
treeMap.set("gander", 356);
let result = treeMap.getLowerKey("sparrow");
```
......@@ -349,10 +353,10 @@ Obtains the key that is placed next to the input key in this container.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356);
treeMap.set("zdfgsd", 356);
let result = treeMap.getHigherKey("sdfs");
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
treeMap.set("gander", 356);
let result = treeMap.getHigherKey("sparrow");
```
### replace
......@@ -380,8 +384,8 @@ Replaces an element in this container.
```ts
let treeMap = new TreeMap();
treeMap.set("sdfs", 123);
let result = treeMap.replace("sdfs", 357);
treeMap.set("sparrow", 123);
let result = treeMap.replace("sparrow", 357);
```
......@@ -397,8 +401,8 @@ Clears this container and sets its length to **0**.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356);
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
treeMap.clear();
```
......@@ -421,8 +425,8 @@ Obtains an iterator that contains all the keys in this container.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356);
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
let iter = treeMap.keys();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -450,8 +454,8 @@ Obtains an iterator that contains all the values in this container.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356);
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
let iter = treeMap.values();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -487,8 +491,8 @@ callbackfn
```ts
let treeMap = new TreeMap();
treeMap.set("sdfs", 123);
treeMap.set("dfsghsf", 357);
treeMap.set("sparrow", 123);
treeMap.set("gull", 357);
treeMap.forEach((value, key) => {
console.log("value:" + value, key);
});
......@@ -513,8 +517,8 @@ Obtains an iterator that contains all the elements in this container.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356);
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
let iter = treeMap.entries();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -542,8 +546,8 @@ Obtains an iterator, each item of which is a JavaScript object.
```ts
let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356);
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
// Method 1:
for (let item of treeMap) {
......
......@@ -10,6 +10,9 @@
Recommended use case: Use **TreeSet** when you need to store data in sorted order.
This topic uses the following to identify the use of generics:
- T: Type
## Modules to Import
```ts
......@@ -29,7 +32,7 @@ import TreeSet from '@ohos.util.TreeSet';
### constructor
constructor(comparator?:(firstValue: T, secondValue: T) => boolean)
constructor(comparator?: (firstValue: T, secondValue: T) => boolean)
A constructor used to create a **TreeSet** instance.
......@@ -118,8 +121,8 @@ Obtains the value of the first element in this container.
```ts
let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
treeSet.add("squirrel");
treeSet.add("sparrow");
let result = treeSet.getFirstValue();
```
......@@ -142,8 +145,8 @@ Obtains the value of the last element in this container.
```ts
let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
treeSet.add("squirrel");
treeSet.add("sparrow");
let result = treeSet.getLastValue();
```
......@@ -172,7 +175,7 @@ Adds an element to this container.
```ts
let treeSet = new TreeSet();
let result = treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
let result = treeSet.add("squirrel");
```
......@@ -200,9 +203,9 @@ Removes the element with the specified key from this container.
```ts
let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
let result = treeSet.remove("sdfs");
treeSet.add("squirrel");
treeSet.add("sparrow");
let result = treeSet.remove("sparrow");
```
......@@ -230,10 +233,10 @@ Obtains the value that is placed in front of the input key in this container.
```ts
let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
treeSet.add("zdfgsd");
let result = treeSet.getLowerValue("sdfs");
treeSet.add("squirrel");
treeSet.add("sparrow");
treeSet.add("gander");
let result = treeSet.getLowerValue("sparrow");
```
......@@ -261,10 +264,10 @@ Obtains the value that is placed next to the input key in this container.
```ts
let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
treeSet.add("zdfgsd");
let result = treeSet.getHigherValue("sdfs");
treeSet.add("squirrel");
treeSet.add("sparrow");
treeSet.add("gander");
let result = treeSet.getHigherValue("sparrow");
```
......@@ -286,8 +289,8 @@ Removes the first element in this container.
```ts
let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
treeSet.add("squirrel");
treeSet.add("sparrow");
let result = treeSet.popFirst();
```
......@@ -310,8 +313,8 @@ Removes the last element in this container.
```ts
let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
treeSet.add("squirrel");
treeSet.add("sparrow");
let result = treeSet.popLast();
```
......@@ -328,8 +331,8 @@ Clears this container and sets its length to **0**.
```ts
let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
treeSet.add("squirrel");
treeSet.add("sparrow");
treeSet.clear();
```
......@@ -352,8 +355,8 @@ Obtains an iterator that contains all the values in this container.
```ts
let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
treeSet.add("squirrel");
treeSet.add("sparrow");
let iter = treeSet.values();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -389,8 +392,8 @@ callbackfn
```ts
let treeSet = new TreeSet();
treeSet.add("sdfs");
treeSet.add("dfsghsf");
treeSet.add("sparrow");
treeSet.add("gull");
treeSet.forEach((value, key) => {
console.log("value:" + value, key)
});
......@@ -415,8 +418,8 @@ Obtains an iterator that contains all the elements in this container.
```ts
let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
treeSet.add("squirrel");
treeSet.add("sparrow");
let iter = treeSet.entries();
let temp = iter.next().value;
while(temp != undefined) {
......@@ -445,8 +448,8 @@ Obtains an iterator, each item of which is a JavaScript object.
```ts
let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
treeSet.add("squirrel");
treeSet.add("sparrow");
// Method 1:
for (let item of treeSet) {
......
......@@ -10,6 +10,9 @@ Both **Vector** and **[ArrayList](js-apis-arraylist.md)** are implemented based
**Recommended use case**: Use **Vector** when the data volume is large.
This topic uses the following to identify the use of generics:
- T: Type
## Modules to Import
```ts
......@@ -71,7 +74,7 @@ let result = vector.add("a");
let result1 = vector.add(1);
let b = [1, 2, 3];
vector.add(b);
let c = {name : "lala", age : "13"};
let c = {name : "Dylon", age : "13"};
let result3 = vector.add(c);
```
......@@ -123,9 +126,9 @@ Checks whether this container has the specified element.
```ts
let vector = new Vector();
let result = vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
vector.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
let result1 = vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
let result = vector.has("squirrel");
vector.add("squirrel");
let result1 = vector.has("squirrel");
```
### getIndexOf
......@@ -862,7 +865,6 @@ Obtains an iterator. Each item of the iterator is a JavaScript object.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
| IterableIterator&lt;T&gt; | Iterator obtained.|
......
......@@ -2,7 +2,6 @@
The **WindowAnimationManager** module provides APIs to listen for application start/exit events and window minimization/maximization events and associate animations with these events.
> **NOTE**
>
> The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
......@@ -32,7 +31,7 @@ Before using other APIs of **windowAnimationManager**, you must call this API to
**Example**
```js
var controller = {
let controller = {
onStartAppFromLauncher(startingWindowTarget: windowAnimationManager.WindowAnimationTarget, finishCallback: windowAnimationManager.WindowAnimationFinishedCallback): void {
console.log('onStartAppFromLauncher, the startingWindowTarget is: ' + startingWindowTarget);
finishCallback.onAnimationFinish();
......@@ -89,8 +88,8 @@ Minimizes the window that displays the animation. This API uses an asynchronous
**Example**
```js
var target: WindowAnimationTarget = undefined;
var controller = {
let target: WindowAnimationTarget = undefined;
let controller = {
onStartAppFromLauncher(startingWindowTarget: windowAnimationManager.WindowAnimationTarget, finishCallback: windowAnimationManager.WindowAnimationFinishedCallback): void {
console.log('onStartAppFromLauncher, the startingWindowTarget is: ' + startingWindowTarget);
finishCallback.onAnimationFinish();
......@@ -128,7 +127,7 @@ var controller = {
windowAnimationManager.setController(controller)
var finishedCallback = null;
let finishedCallback = null;
windowAnimationManager.minimizeWindowWithAnimation(target, (err, data) => {
if (err.code) {
console.error('Failed to minimize the window target. Cause: ' + JSON.stringify(err));
......@@ -165,8 +164,8 @@ Minimizes the window that displays the animation. This API uses a promise to ret
**Example**
```js
var target: WindowAnimationTarget = undefined;
var controller = {
let target: WindowAnimationTarget = undefined;
let controller = {
onStartAppFromLauncher(startingWindowTarget: windowAnimationManager.WindowAnimationTarget, finishCallback: windowAnimationManager.WindowAnimationFinishedCallback): void {
console.log('onStartAppFromLauncher, the startingWindowTarget is: ' + startingWindowTarget);
finishCallback.onAnimationFinish();
......
......@@ -339,8 +339,8 @@ let strXml =
let arrayBuffer = new ArrayBuffer(strXml.length);
let bufView = new Uint8Array(arrayBuffer);
let strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
bufView[i] = strXml.charCodeAt(i);
for (var tmp = 0; tmp < strLen; ++tmp) {
bufView[tmp] = strXml.charCodeAt(tmp);
}
let that = new xml.XmlPullParser(arrayBuffer);
let arrTag = {};
......
......@@ -54,7 +54,7 @@ You can create a subwindow, such as a dialog box, and set its properties.
import window from '@ohos.window';
let windowClass = null;
// 1. Method 1: Create a subwindow.
// Method 1: Create a subwindow.
window.create("subWindow", window.WindowType.TYPE_APP, (err, data) => {
if (err.code) {
console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
......@@ -63,7 +63,7 @@ You can create a subwindow, such as a dialog box, and set its properties.
console.info('Succeeded in creating subWindow. Data: ' + JSON.stringify(data));
windowClass = data;
});
// 1. Method 2: Obtain a subwindow.
// Method 2: Obtain a subwindow.
window.getTopWindow((err, data) => {
if (err.code) {
console.error('Failed to get the subWindow. Cause: ' + JSON.stringify(err));
......@@ -72,7 +72,7 @@ You can create a subwindow, such as a dialog box, and set its properties.
console.info('Succeeded in getting subWindow. Data: ' + JSON.stringify(data));
windowClass = data;
});
// 1. Method 3: Find a subwindow.
// Method 3: Find a subwindow.
window.find("subWindow", (err, data) => {
if (err.code) {
console.error('Failed to find the subWindow. Cause: ' + JSON.stringify(err));
......@@ -88,7 +88,7 @@ You can create a subwindow, such as a dialog box, and set its properties.
After the subwindow is created, you can set its properties, such as the size, position, background color, and brightness.
```js
// 2. Move the subwindow.
// Move the subwindow.
windowClass.moveTo(300, 300, (err, data) => {
if (err.code) {
console.error('Failed to move the window. Cause:' + JSON.stringify(err));
......@@ -96,7 +96,7 @@ You can create a subwindow, such as a dialog box, and set its properties.
}
console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data));
});
// 2. Change the size of the subwindow.
// Change the size of the subwindow.
windowClass.resetSize(500, 1000, (err, data) => {
if (err.code) {
console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
......@@ -111,14 +111,14 @@ You can create a subwindow, such as a dialog box, and set its properties.
Call `loadContent` and `show` to load and display the content in the subwindow.
```js
// 3. Load the page content to the subwindow.
// Load the page content to the subwindow.
windowClass.loadContent("pages/page2", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
// 3. Show the subwindow.
// Show the subwindow.
windowClass.show((err, data) => {
if (err.code) {
console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
......@@ -134,7 +134,7 @@ You can create a subwindow, such as a dialog box, and set its properties.
When the subwindow is no longer needed, you can call `destroy` to destroy it.
```js
// 4. Destroy the subwindow when a click event outside the window is detected.
// Destroy the subwindow when a click event outside the window is detected.
windowClass.on('touchOutside', () => {
console.info('touch outside');
windowClass.destroy((err, data) => {
......@@ -167,7 +167,7 @@ To create a better video watching and gaming experience, you can use the immersi
import window from '@ohos.window';
let mainWindowClass = null;
// 1. Obtain the main window.
// Obtain the main window.
window.getTopWindow((err, data) => {
if (err.code) {
console.error('Failed to get the subWindow. Cause: ' + JSON.stringify(err));
......@@ -185,7 +185,7 @@ To create a better video watching and gaming experience, you can use the immersi
- Method 3: Call `setLayoutFullScreen` to enable the full-screen mode for the main window layout. Call `setSystemProperties` to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window.
```js
// 2. Use method 1 to implement the immersive effect.
// Use method 1 to implement the immersive effect.
let isFullScreen = true;
mainWindowClass.setFullScreen(isFullScreen, (err, data) => {
if (err.code) {
......@@ -194,7 +194,7 @@ To create a better video watching and gaming experience, you can use the immersi
}
console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
});
// 2. Use method 2 to implement the immersive effect.
// Use method 2 to implement the immersive effect.
let names = [];
mainWindowClass.setSystemBarEnable(names, (err, data) => {
if (err.code) {
......@@ -203,7 +203,7 @@ To create a better video watching and gaming experience, you can use the immersi
}
console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
});
// 2. Use method 3 to implement the immersive effect.
// Use method 3 to implement the immersive effect.
let isLayoutFullScreen = true;
mainWindowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => {
if (err.code) {
......@@ -236,14 +236,14 @@ To create a better video watching and gaming experience, you can use the immersi
Call `loadContent` and `show` to load and display the content in the immersive window.
```js
// 3. Load the page content to the immersive window.
// Load the page content to the immersive window.
mainWindowClass.loadContent("pages/page3", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
// 3. Show the immersive window.
// Show the immersive window.
mainWindowClass.show((err, data) => {
if (err.code) {
console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
......
......@@ -29,14 +29,17 @@ For easier maintenance and evolution, comply with the following principles when
1. Make sure the software comes from a clearly defined upstream community.
2. Provide a sound reason for software introduction. If the software to be introduced already exists in the OpenHarmony project, reuse it to avoid maintenance complexity caused by coexistence of multiple versions.
3. Introduce the software in the form of source code, rather than binary files. If a piece of software needs to be introduced in the form of binary files, the PMC should review the request and make a decision.
4. Make sure the software can be correctly built on the OpenHarmony project. If the software has dependency software that has not been introduced, or the running or build of the software depends on a component that cannot be introduced, the PMC should review the request and make a decision.
5. Place the software in an independent code repository or directory and name it in the format of **third_party_*****softwareName***, where *softwareName* must be an official name.
4. Make sure the software can be correctly built on the OpenHarmony project. If the software has dependency software that has not been introduced, or the running or build of the software depends on a component that cannot be introduced, the SIG-Architecture should review the request and make a decision.
5. Place the software in an independent code repository and name it in the format of **third_party_*****softwareName***, where *softwareName* must be an official name.
6. Retain the directory structure, license, and copyright information of the official code repository of the software. Do not modify the original license and copyright information.
7. Do not introduce any software version that has not been officially released, for example, the Beta version.
8. Do not introduce any software version that has high-risk vulnerabilities and does not provide solutions.
9. If you need to modify the software, place the new code in the software repository and ensure that the new code meets the license requirements of the software. Retain the original license for the modified files, and use the same license for the new files (recommended).
10. Provide the **README.OpenSource** file in the root directory of the software repository. Include the following information in the file: software name, license, license file location, version, upstream community address of the corresponding version, software maintenance owner, function description, and introduction reason.
11. Make sure the software you introduce is under the custody of a domain SIG. In principle, the PMC will deny the introduction of a piece of software without the confirmation of the SIG QA and the corresponding domain SIG. When introducing multiple pieces of software at a time, you can ask the PMC to hold a temporary review meeting between SIGs for faster introduction. If you want to introduce a piece of software but fail to meet the preceding requirements, send an email to law@openatom.org.
11. Make sure the software you introduce is under the custody of a domain SIG. In principle, the SIG-Architecture will deny the introduction of a piece of software without the confirmation of the SIG-Compliance and the corresponding domain SIG. When introducing multiple pieces of software at a time, you can ask the PMC to hold a temporary review meeting between SIGs for faster introduction. If you want to introduce a piece of software but fail to meet the preceding requirements, send an email to law@openatom.org.
12. When software introduction depends on other dependency software, it is not allowed to nest the dependency software in the subdirectory of the software introduction, and all dependency softwares must be placed in separate repository, and name it in the format of **third_party_*****softwareName***, because nested placement of dependency software may lead to multiple versions of the same software, old versions of security vulnerabilities cannot be fixed in a timely, and will risk the opensource compliance issues.
- Dependency software are named in the compiled BUILD.gn with part name by prefixing the newly software introduction name, e.g. part_name = "software_introduction_name_dependency software_name".
- The inter-component dependencies between software introduction and dependency software are resolved via external_deps.
### Software Introduction Process
......
# Writing Instructions<a name="EN-US_TOPIC_0000001053707964"></a>
# Writing Instructions
This document describes the writing specifications for contributing OpenHarmony documents.
## Naming Specifications<a name="section6823246189"></a>
## Naming Specifications
To submit a new document, create a new **.md** file in the **doc** directory of the project code on Gitee. The file name must be in the _xxx-xxx_**.md** format.
For example, a document that describes writing specifications can be named **write-standard.md**.
## Content Specifications<a name="section650663210183"></a>
## Content Specifications
The content should be concise and intuitive. Introductory documents describe principles, architecture, and design ideas in a concise manner, and operation documents describe key steps to help other developers. Chinese is preferred. It is recommended that both Chinese and English be supported. The OpenHarmony will be updated continuously to ensure the synchronization between Chinese and English.
......@@ -73,7 +73,8 @@ Pictures used in **OpenHarmony\_DOCUMENTS/docs/quick-start/write-standard.md**
If a self-made picture is used, refer to the following figure to configure the color. The format can be **png**, **jpg**, **gif**, and so on.
**Figure 1** Example<a name="fig952595173513"></a>
**Figure 1** Example
![](figures/example.png "example")
For screenshots, see the requirements below. If you need to highlight key information in the figure, add a red box or text remarks.
......@@ -88,7 +89,7 @@ English font: Arial
Font size: 10 pt
**Figure 2** <a name="fig1472123913217"></a>
**Figure 2**
**Table**
......@@ -109,38 +110,11 @@ Output
**Table 1** Parameters
<a name="table163931041183019"></a>
<table><thead align="left"><tr id="row1393134183014"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p1539314418307"><a name="p1539314418307"></a><a name="p1539314418307"></a>Table</p>
</th>
<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p1339324120303"><a name="p1339324120303"></a><a name="p1339324120303"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p13932041133012"><a name="p13932041133012"></a><a name="p13932041133012"></a>Note</p>
</th>
</tr>
</thead>
<tbody><tr id="row1839304110309"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p4393174143014"><a name="p4393174143014"></a><a name="p4393174143014"></a>first</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p6393141133013"><a name="p6393141133013"></a><a name="p6393141133013"></a>standard</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p17393184112307"><a name="p17393184112307"></a><a name="p17393184112307"></a>None</p>
</td>
</tr>
<tr id="row1039318412306"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p113941541103012"><a name="p113941541103012"></a><a name="p113941541103012"></a>second</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p83941841153016"><a name="p83941841153016"></a><a name="p83941841153016"></a>outstanding</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1539404114305"><a name="p1539404114305"></a><a name="p1539404114305"></a>5</p>
</td>
</tr>
<tr id="row6547101813118"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p35483184313"><a name="p35483184313"></a><a name="p35483184313"></a>third</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1554821817318"><a name="p1554821817318"></a><a name="p1554821817318"></a>inside</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p15548201819310"><a name="p15548201819310"></a><a name="p15548201819310"></a>with</p>
</td>
</tr>
</tbody>
</table>
| Tables | Type | Note |
| ------ | :---------: | ---: |
| first | standard | None |
| second | outstanding | 5 |
| third | inside | with |
**Code**
......
......@@ -94,7 +94,7 @@ The Face_auth driver provides basic facial authentication capabilities for the U
| API | Description |
| ------------------------------------------------------------ | ------------------------ |
| IExecutorCallback::OnResult(int32_t code, const std::vector<uint8_t>& extraInfo) | Called to return the operation result. |
| IExecutorCallback::OnAcquireInfo(int32_t code, const std::vector<uint8_t>& extraInfo) | Called to return the interaction information about the operation process.|
| IExecutorCallback::OnTip(int32_t code, const std::vector<uint8_t>& extraInfo) | Called to return the interaction information about the operation process.|
### How to Develop
......
......@@ -108,7 +108,7 @@ The fingerprint_auth driver provides stable basic fingerprint authentication cap
| API | Description |
| ------------------------------------------------------------ | ------------------------ |
| IExecutorCallback::OnResult(int32_t code, const std::vector<uint8_t>& extraInfo) | Called to return the operation result. |
| IExecutorCallback::OnAcquireInfo(int32_t code, const std::vector<uint8_t>& extraInfo) | Called to return the interaction information about the operation process.|
| IExecutorCallback::OnTip(int32_t code, const std::vector<uint8_t>& extraInfo) | Called to return the interaction information about the operation process.|
### How to Develop
......
......@@ -342,8 +342,8 @@ The development procedure is as follows:
}
info.executorType = EXECUTOR_TYPE;
info.remainTimes = infoRet.remainTimes;
info.freezingTime = infoRet.freezingTime;
info.remainAttempts = infoRet.remainTimes;
info.lockoutDuration = infoRet.freezingTime;
return HDF_SUCCESS;
}
......
......@@ -53,7 +53,7 @@ The following uses the RTL8720 development board provided by Realtek as an examp
2. Create a directory for kernel adaptation and configure the **config.gni** file of the development board.
For example, to adapt the LiteOS-A kernel to the RTL8720 development board, configure the **device/board/realtek/rtl8720/liteo_a/config.gni** file as follows:
For example, to adapt the LiteOS-A kernel to the RTL8720 development board, configure the **device/board/realtek/rtl8720/liteos_a/config.gni** file as follows:
```shell
# Kernel type, e.g. "linux", "liteos_a", "liteos_m".
......
# JS API Changes of the Distributed Scheduler Subsystem
The table below lists the APIs changes of the distributed scheduler subsystem in OpenHarmony 3.2 Beta1 over OpenHarmony 3.1 Release.
## API Changes
| Module| Class| Method/Attribute/Enumeration/Constant| Change Type|
|---|---|---|---|
| ohos.continuation.continuationManager | continuationManager | on(type: "deviceConnect", token: number, callback: Callback\<Array\<ContinuationResult>>): void; | Added|
| ohos.continuation.continuationManager | continuationManager | off(type: "deviceConnect", token: number): void; | Added|
| ohos.continuation.continuationManager | continuationManager | on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>): void; | Added|
| ohos.continuation.continuationManager | continuationManager | off(type: "deviceDisconnect", token: number): void; | Added|
| ohos.continuation.continuationManager | continuationManager | on(type: "deviceConnect", callback: Callback\<ContinuationResult>): void; | Deprecated|
| ohos.continuation.continuationManager | continuationManager | off(type: "deviceConnect", callback?: Callback\<ContinuationResult>): void; | Deprecated|
| ohos.continuation.continuationManager | continuationManager | on(type: "deviceDisconnect", callback: Callback\<string>): void; | Deprecated|
| ohos.continuation.continuationManager | continuationManager | off(type: "deviceDisconnect", callback?: Callback\<string>): void; | Deprecated|
......@@ -12,4 +12,4 @@
- [三四方库使用常见问题](faqs-third-party-library.md)
- [IDE使用常见问题](faqs-ide.md)
- [hdc_std命令使用常见问题](faqs-hdc-std.md)
- [开发板](faqs-development-board.md)
- [开发板使用常见问题](faqs-development-board.md)
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册