提交 f923beef 编写于 作者: G Gloria

Update docs against 12416+12895+12486+13383+12423+12419+12424

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 2fc4f937
# @ohos.ability.dataUriUtils
The **DataUriUtils** module provides APIs to handle utility classes for objects using the **DataAbilityHelper** schema. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI. This module will be replaced by the **app.ability.dataUriUtils** module in the near future. You are advised to use the **[@ohos.app.ability.dataUriUtils](js-apis-app-ability-dataUriUtils.md)** module.
The **DataUriUtils** module provides APIs to process URI objects. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI. This module will be replaced by the **app.ability.dataUriUtils** module in the near future. You are advised to use the **[@ohos.app.ability.dataUriUtils](js-apis-app-ability-dataUriUtils.md)** module.
> **NOTE**
>
......@@ -24,18 +24,18 @@ Obtains the ID attached to the end of a given URI.
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object from which the ID is to be obtained.|
| uri | string | Yes | Target URI object.|
**Return value**
| Type | Description |
| ------ | ------------------------ |
| number | ID obtained from the URI object.|
| number | ID obtained.|
**Example**
```ts
dataUriUtils.getId("com.example.dataUriUtils/1221")
let id = dataUriUtils.getId("com.example.dataUriUtils/1221");
```
......@@ -52,7 +52,7 @@ Attaches an ID to the end of a given URI.
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object to which an ID is to be attached.|
| uri | string | Yes | Target URI object.|
| id | number | Yes | ID to be attached. |
**Return value**
......@@ -64,10 +64,10 @@ Attaches an ID to the end of a given URI.
**Example**
```ts
var idint = 1122;
dataUriUtils.attachId(
let id = 1122;
let uri = dataUriUtils.attachId(
"com.example.dataUriUtils",
idint,
id,
)
```
......@@ -96,9 +96,11 @@ Deletes the ID from the end of a given URI.
**Example**
```ts
dataUriUtils.deleteId("com.example.dataUriUtils/1221")
let uri = dataUriUtils.deleteId("com.example.dataUriUtils/1221")
```
## dataUriUtils.updateId
updateId(uri: string, id: number): string
......@@ -111,7 +113,7 @@ Updates the ID in a given URI.
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ------------------- |
| uri | string | Yes | URI object to be updated.|
| uri | string | Yes | Target URI object.|
| id | number | Yes | New ID. |
**Return value**
......@@ -123,9 +125,9 @@ Updates the ID in a given URI.
**Example**
```ts
var idint = 1122;
dataUriUtils.updateId(
"com.example.dataUriUtils",
idint
let id = 1122;
let uri = dataUriUtils.updateId(
"com.example.dataUriUtils/1221",
id
)
```
# ohos.app.ability.dataUriUtils
# @ohos.app.ability.dataUriUtils
The **DataUriUtils** module provides APIs to handle utility classes for objects using the **DataAbilityHelper** schema. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI.
The **DataUriUtils** module provides APIs to process URI objects. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI.
> **NOTE**
>
......@@ -24,13 +24,13 @@ Obtains the ID attached to the end of a given URI.
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object from which the ID is to be obtained.|
| uri | string | Yes | Target URI object.|
**Return value**
| Type | Description |
| ------ | ------------------------ |
| number | ID obtained from the URI object.|
| number | ID obtained.|
**Example**
......@@ -49,7 +49,7 @@ try {
attachId(uri: string, id: number): string
Attaches an ID to the end of a given URI. It can be used to generate a new URI.
Attaches an ID to the end of a given URI.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -57,7 +57,7 @@ Attaches an ID to the end of a given URI. It can be used to generate a new URI.
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object to which an ID is to be attached.|
| uri | string | Yes | Target URI object.|
| id | number | Yes | ID to be attached. |
**Return value**
......@@ -69,11 +69,11 @@ Attaches an ID to the end of a given URI. It can be used to generate a new URI.
**Example**
```ts
var idint = 1122;
var id = 1122;
try {
var uri = dataUriUtils.attachId(
"com.example.dataUriUtils",
idint,
id,
)
console.info('attachId the uri is: ' + uri)
} catch (err) {
......@@ -130,7 +130,7 @@ Updates the ID in a given URI.
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ------------------- |
| uri | string | Yes | URI object to be updated.|
| uri | string | Yes | Target URI object.|
| id | number | Yes | New ID. |
**Return value**
......@@ -144,10 +144,10 @@ Updates the ID in a given URI.
```ts
try {
var idint = 1122;
var id = 1122;
var uri = dataUriUtils.updateId(
"com.example.dataUriUtils",
idint
"com.example.dataUriUtils/1221",
id
)
} catch (err) {
console.error('delete uri err, check the input uri' + err)
......
......@@ -3,6 +3,7 @@
The **Configuration** module defines environment change information.
> **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.
> This module is deprecated since API version 9. You are advised to use [@ohos.app.ability.Configuration](js-apis-app-ability-configuration.md) instead.
......@@ -16,7 +17,7 @@ import Configuration from '@ohos.application.Configuration'
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| language<sup>8+</sup> | string | Yes| Yes| Language of the application.|
| language<sup>8+</sup> | string | Yes| Yes| Language of the application, for example, **zh**.|
| colorMode<sup>8+</sup> | [ColorMode](js-apis-application-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
| direction<sup>9+</sup> | [Direction](js-apis-application-configurationConstant.md#configurationconstantdirection9) | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
| screenDensity<sup>9+</sup> | [ScreenDensity](js-apis-application-configurationConstant.md#configurationconstantscreendensity9) | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).|
......@@ -29,10 +30,10 @@ For details about the fields, see the **ohos.application.Configuration.d.ts** fi
```ts
import hilog from '@ohos.hilog';
import Ability from '@ohos.application.Ability'
import Window from '@ohos.window'
import UIAbility from '@ohos.app.ability.UIAbility';
import Window from '@ohos.window';
export default class MainAbility extends Ability {
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
}
......
......@@ -18,11 +18,11 @@ You can obtain the value of this constant by calling the **ConfigurationConstant
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Value| Description|
| Name| Value| Description|
| -------- | -------- | -------- |
| COLOR_MODE_NOT_SET | -1 | Unspecified color mode.|
| COLOR_MODE_DARK | 0 | Dark mode.|
| COLOR_MODE_LIGHT | 1 | Light mode.|
| COLOR_MODE_NOT_SET | -1 | Unspecified color mode.|
| COLOR_MODE_DARK | 0 | Dark mode.|
| COLOR_MODE_LIGHT | 1 | Light mode.|
## ConfigurationConstant.Direction<sup>9+</sup>
......@@ -31,11 +31,11 @@ You can obtain the value of this constant by calling the **ConfigurationConstant
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Value| Description|
| Name| Value| Description|
| -------- | -------- | -------- |
| DIRECTION_NOT_SET | -1 | Unspecified direction.|
| DIRECTION_VERTICAL | 0 | Vertical direction.|
| DIRECTION_HORIZONTAL | 1 | Horizontal direction.|
| DIRECTION_NOT_SET | -1 | Unspecified direction.|
| DIRECTION_VERTICAL | 0 | Vertical direction.|
| DIRECTION_HORIZONTAL | 1 | Horizontal direction.|
## ConfigurationConstant.ScreenDensity<sup>9+</sup>
......@@ -44,12 +44,12 @@ You can obtain the value of this constant by calling the **ConfigurationConstant
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Value| Description|
| Name| Value| Description|
| -------- | -------- | -------- |
| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.|
| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.|
| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.|
| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.|
| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.|
| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.|
| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.|
| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.|
| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.|
| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.|
| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.|
| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.|
| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.|
| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.|
# AppStateData
The **AppStateData** module defines the application state data.
The **AppStateData** module defines the application state data, which can be obtained through [getForegroundApplications](js-apis-app-ability-appManager.md#appmanagergetforegroundapplications).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**System API**: This module is marked as @systemapi and not visible to third-party applications.
| Name | Type | Mandatory| Description |
| ----------- | -------- | ---- | ------------------------------------------------------------ |
| bundleName<sup>8+</sup> | string | No | Bundle name of the application. |
| uid<sup>8+</sup> | number | No | User ID.|
| state<sup>8+</sup> | number | No | Application state.|
| Name | Type | Mandatory | Description |
| ------------------------- | ------ | ---- | --------- |
| bundleName<sup>8+</sup> | string | No | Bundle name.|
| uid<sup>8+</sup> | number | No | UID of the application. |
| state<sup>8+</sup> | number | No | Application state.<br>**0**: The application is being initialized.<br>**1**: The application has been initialized and is ready.<br>**2**: The application is running in the foreground.<br>**3**: The application is having the focus. (This state is reserved.)<br>**4**: The application is running in the background.<br>**5**: The application has exited.|
**Example**
```ts
import appManager from "@ohos.application.appManager"
import appManager from "@ohos.app.ability.appManager"
appManager.getForegroundApplications((error, data) => {
for(let i=0; i<data.length; i++) {
let appStateData = data[i];
console.info('appStateData.bundleName: ' + appStateData.bundleName);
console.info('appStateData.uid: ' + appStateData.uid);
console.info('appStateData.state: ' + appStateData.state);
}
});
function getForegroundAppInfos() {
appManager.getForegroundApplications((error, data) => {
if (error && error.code) {
console.log('getForegroundApplications failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
for (let i = 0; i < data.length; i++) {
let appStateData = data[i];
console.log('appStateData.bundleName: ' + appStateData.bundleName);
console.log('appStateData.uid: ' + appStateData.uid);
console.log('appStateData.state: ' + appStateData.state);
}
});
}
```
# MissionListener
The **MissionListener** module defines the listeners used to observe the mission status.
The **MissionListener** module defines the listeners used to observe the mission status. The listeners can be registered by using [on](js-apis-app-ability-missionManager.md#missionmanageron).
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
......@@ -16,7 +16,7 @@ The **MissionListener** module defines the listeners used to observe the mission
**Example**
```ts
import missionManager from '@ohos.application.missionManager'
import missionManager from '@ohos.app.ability.missionManager'
let listener = {
onMissionCreated: function (mission) {
......@@ -38,5 +38,10 @@ let listener = {
console.log("onMissionClosed mission: " + JSON.stringify(mission));
}
};
let listenerid = missionManager.registerMissionListener(listener);
try {
let listenerId = missionManager.on("mission", listener);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
# TriggerInfo
The **TriggerInfo** module defines the information required for triggering the WantAgent.
The **TriggerInfo** module defines the information required for triggering the WantAgent. The information is used as an input parameter of [trigger](js-apis-app-ability-wantAgent.md#wantagenttrigger).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Mandatory| Description |
| ---------- | --- |-------------------- | ----------- |
| code | number | Yes | Result code.|
| code | number | Yes | Custom result code provided for the target WantAgent.|
| want | Want | No | Want. |
| permission | string | No | Permission. |
| extraInfo | {[key: string]: any} | No | Extra information. |
**Example**
```ts
import wantAgent from '@ohos.wantAgent';
let wantAgentInfo = {
wants: [
{
deviceId: "",
bundleName: "com.example.apicoverhaptest",
abilityName: "com.example.apicoverhaptest.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true.true,false}",
parameters: {
myKey0: 2222
}
}
],
operationType: wantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG],
extraInfo:{
"key": "value"
}
}
let triggerInfo = {
code: 0,
want: {
deviceId: "",
bundleName: "com.example.apicoverhaptest",
abilityName: "com.example.apicoverhaptest.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true.true,false}",
parameters: {
myKey0: 2222
}
},
permission: ""
extraInfo:{
"key": "value"
}
}
wantAgent.trigger(wantAgentInfo, triggerInfo).then((data) =>{
console.info("trigger data: " + JSON.stringify(data));
}).catch((err) => {
console.error("trigger err: " + JSON.stringify(err));
})
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册