未验证 提交 966c20b6 编写于 作者: K king_he 提交者: Gitee

update en/application-dev/reference/apis/js-apis-Context.md.

Signed-off-by: Nking_he <6384784@qq.com>
上级 51370f2c
# Context Module
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
> 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
......@@ -30,9 +30,9 @@ If this API is called for the first time, a root directory will be created.
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the local root directory.|
| callback | AsyncCallback\<string> | Yes | Callback used to return the local root directory. |
**Example**
......@@ -60,7 +60,7 @@ If this API is called for the first time, a root directory will be created.
| Type | Description |
| ---------------- | ---------------------- |
| Promise\<string> | Promise used to return the local root directory.|
| Promise\<string> | Promise used to return the local root directory. |
**Example**
......@@ -84,11 +84,11 @@ Verifies whether a specific PID and UID have the given permission. This API uses
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| ---------- | --------------------------------------- | ---- | ------------------------------------- |
| permission | string | Yes | Name of the permission to verify. |
| options | [PermissionOptions](#permissionoptions) | Yes | Permission options. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission. |
**Example**
......@@ -113,10 +113,10 @@ Verifies whether the current PID and UID have the given permission. This API use
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| ---------- | ---------------------- | ---- | ------------------------------------- |
| permission | string | Yes | Name of the permission to verify. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission. |
**Example**
......@@ -136,16 +136,16 @@ Verifies whether a specific PID and UID have the given permission. This API uses
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| ---------- | --------------------------------------- | ---- | ---------------- |
| permission | string | Yes | Name of the permission to verify.|
| permission | string | Yes | Name of the permission to verify. |
| options | [PermissionOptions](#permissionoptions) | No | Permission options. |
**Return value**
| Type | Description |
| ---------------- | ----------------------------------------------------------- |
| Promise\<number> | Promise used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
| Promise\<number> | Promise used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission. |
**Example**
......@@ -171,10 +171,10 @@ Requests certain permissions from the system. This API uses an asynchronous call
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- |
| permissions | Array\<string> | Yes | Permissions to request. This parameter cannot be **null**. |
| requestCode | number | Yes | Request code to be passed to **PermissionRequestResult**.|
| requestCode | number | Yes | Request code to be passed to **PermissionRequestResult**. |
| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes | Permission request result. |
**Example**
......@@ -207,9 +207,9 @@ Obtains information about the current application. This API uses an asynchronous
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<ApplicationInfo> | Yes | Callback used to return the application information.|
| callback | AsyncCallback\<ApplicationInfo> | Yes | Callback used to return the application information. |
**Example**
......@@ -233,7 +233,7 @@ Obtains information about the current application. This API uses a promise to re
| Type | Description |
| ------------------------- | ------------------ |
| Promise\<ApplicationInfo> | Promise used to return the application information.|
| Promise\<ApplicationInfo> | Promise used to return the application information. |
**Example**
......@@ -258,9 +258,9 @@ Obtains the bundle name of the current ability. This API uses an asynchronous ca
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ----------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.|
| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name. |
**Example**
......@@ -284,7 +284,7 @@ Obtains the bundle name of the current ability. This API uses a promise to retur
| Type | Description |
| ---------------- | ------------------------- |
| Promise\<string> | Promise used to return the bundle name.|
| Promise\<string> | Promise used to return the bundle name. |
**Example**
......@@ -309,9 +309,9 @@ Obtains information about the current process, including the PID and process nam
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<ProcessInfo> | Yes | Callback used to return the process information.|
| callback | AsyncCallback\<ProcessInfo> | Yes | Callback used to return the process information. |
**Example**
......@@ -335,7 +335,7 @@ Obtains information about the current process, including the PID and process nam
| Type | Description |
| --------------------- | -------------- |
| Promise\<ProcessInfo> | Promise used to return the process information.|
| Promise\<ProcessInfo> | Promise used to return the process information. |
**Example**
......@@ -362,9 +362,9 @@ This API is available only to Page abilities.
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ---------------------------------------------- |
| callback | AsyncCallback\<ElementName> | Yes | Callback used to return the **ohos.bundle.ElementName** object.|
| callback | AsyncCallback\<ElementName> | Yes | Callback used to return the **ohos.bundle.ElementName** object. |
**Example**
......@@ -390,7 +390,7 @@ This API is available only to Page abilities.
| Type | Description |
| --------------------- | ------------------------------------------ |
| Promise\<ElementName> | Promise used to return the **ohos.bundle.ElementName** object.|
| Promise\<ElementName> | Promise used to return the **ohos.bundle.ElementName** object. |
**Example**
......@@ -413,9 +413,9 @@ Obtains the name of the current process. This API uses an asynchronous callback
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | -------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the process name.|
| callback | AsyncCallback\<string> | Yes | Callback used to return the process name. |
**Example**
......@@ -439,7 +439,7 @@ Obtains the name of the current process. This API uses a promise to return the r
| Type | Description |
| ---------------- | -------------------- |
| Promise\<string> | Promise used to return the process name.|
| Promise\<string> | Promise used to return the process name. |
**Example**
......@@ -464,9 +464,9 @@ Obtains the bundle name of the calling ability. This API uses an asynchronous ca
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.|
| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name. |
**Example**
......@@ -490,7 +490,7 @@ Obtains the bundle name of the calling ability. This API uses a promise to retur
| Type | Description |
| --------------- | ------------------------- |
| Promise\<string> | Promise used to return the bundle name.|
| Promise\<string> | Promise used to return the bundle name. |
**Example**
......@@ -513,9 +513,9 @@ Obtains the cache directory of the application on the internal storage. This API
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the cache directory.|
| callback | AsyncCallback\<string> | Yes | Callback used to return the cache directory. |
**Example**
......@@ -543,7 +543,7 @@ Obtains the cache directory of the application on the internal storage. This API
| Type | Description |
| --------------- | ------------------------- |
| Promise\<string> | Promise used to return the cache directory.|
| Promise\<string> | Promise used to return the cache directory. |
**Example**
......@@ -566,9 +566,9 @@ Obtains the file directory of the application on the internal storage. This API
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the file directory.|
| callback | AsyncCallback\<string> | Yes | Callback used to return the file directory. |
**Example**
......@@ -596,7 +596,7 @@ Obtains the file directory of the application on the internal storage. This API
| Type | Description |
| --------------- | ------------------------- |
| Promise\<string> | Promise used to return the file directory.|
| Promise\<string> | Promise used to return the file directory. |
**Example**
......@@ -621,9 +621,9 @@ If the distributed file path does not exist, the system will create one and retu
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the distributed file path. If the distributed file path does not exist, the system will create one and return the created path.|
| callback | AsyncCallback\<string> | Yes | Callback used to return the distributed file path. If the distributed file path does not exist, the system will create one and return the created path. |
**Example**
......@@ -653,7 +653,7 @@ If the distributed file path does not exist, the system will create one and retu
| Type | Description |
| --------------- | ------------------------- |
| Promise\<string> | Promise used to return the distributed file path. If this API is called for the first time, a new path will be created.|
| Promise\<string> | Promise used to return the distributed file path. If this API is called for the first time, a new path will be created. |
**Example**
......@@ -675,9 +675,9 @@ Obtains the application type. This API uses an asynchronous callback to return t
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the application type.|
| callback | AsyncCallback\<string> | Yes | Callback used to return the application type. |
**Example**
......@@ -705,7 +705,7 @@ Obtains the application type. This API uses a promise to return the result.
| Type | Description |
| --------------- | ------------------------- |
| Promise\<string> | Promise used to return the application type.|
| Promise\<string> | Promise used to return the application type. |
**Example**
......@@ -727,9 +727,9 @@ Obtains the **ModuleInfo** object of the application. This API uses an asynchron
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<[HapModuleInfo](#hapmoduleinfo)> | Yes | Callback used to return the **ModuleInfo** object.|
| callback | AsyncCallback\<[HapModuleInfo](#hapmoduleinfo)> | Yes | Callback used to return the **ModuleInfo** object. |
**Example**
......@@ -757,7 +757,7 @@ Obtains the **ModuleInfo** object of the application. This API uses a promise to
| Type | Description |
| --------------- | ------------------------- |
| Promise\<[HapModuleInfo](#hapmoduleinfo)> | Promise used to return the **ModuleInfo** object.|
| Promise\<[HapModuleInfo](#hapmoduleinfo)> | Promise used to return the **ModuleInfo** object. |
**Example**
......@@ -779,9 +779,9 @@ Obtains the version information of the application. This API uses an asynchronou
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes | Callback used to return the version information.|
| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes | Callback used to return the version information. |
**Example**
......@@ -809,7 +809,7 @@ Obtains the version information of the application. This API uses a promise to r
| Type | Description |
| --------------- | ------------------------- |
| Promise\<[AppVersionInfo](#appversioninfo)> | Promise used to return the version information.|
| Promise\<[AppVersionInfo](#appversioninfo)> | Promise used to return the version information. |
**Example**
......@@ -831,9 +831,9 @@ Obtains information of the current ability. This API uses an asynchronous callba
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes |Callback used to return the ability information.|
| callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes |Callback used to return the ability information. |
**Example**
......@@ -861,7 +861,7 @@ Obtains information of the current ability. This API uses a promise to return th
| Type | Description |
| --------------- | ------------------------- |
| Promise\<[AbilityInfo](#abilityInfo)> | Promise used to return the ability information.|
| Promise\<[AbilityInfo](#abilityInfo)> | Promise used to return the ability information. |
**Example**
......@@ -885,7 +885,7 @@ Obtains the context of the application.
| Type | Description |
| --------- |------ |
| Context |Application context.|
| Context |Application context. |
**Example**
......@@ -898,18 +898,18 @@ var context = featureAbility.getContext().getApplicationContext();
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Readable/Writable| Type | Mandatory| Description |
| Name| Readable/Writable | Type | Mandatory | Description |
| ---- | -------- | ------ | ---- | ------ |
| pid | Read-only | number | No | Process ID.|
| uid | Read-only | number | No | User ID.|
| pid | Read-only | number | No | Process ID. |
| uid | Read-only | number | No | User ID. |
## PermissionRequestResult<sup>7+</sup>
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory| Description |
| Name | Readable/Writable | Type | Mandatory | Description |
| ----------- | -------- | -------------- | ---- | ------------------ |
| requestCode | Read-only | number | Yes | Request code passed.|
| requestCode | Read-only | number | Yes | Request code passed. |
| permissions | Read-only | Array\<string> | Yes | Permissions requested. |
| authResults | Read-only | Array\<number> | Yes | Permission request result. |
......@@ -917,7 +917,7 @@ var context = featureAbility.getContext().getApplicationContext();
Describes the HAP module information.
| Name | Type| Readable| Writable| Description|
| Name | Type| Readable | Writable | Description |
| ------ | ------ | ------ | ------ | ------ |
| name | string | Yes | No | Module name. |
| description | string | Yes | No | Module description. |
......@@ -928,17 +928,17 @@ Describes the HAP module information.
| iconId | number | Yes | No | Module icon ID. |
| backgroundImg | string | Yes | No | Module background image. |
| supportedModes | number | Yes | No | Modes supported by the module. |
| reqCapabilities | Array<string> | Yes | No | Capabilities required for module running.|
| deviceTypes | Array<string> | Yes | No | An array of supported device types.|
| reqCapabilities | Array<string> | Yes | No | Capabilities required for module running. |
| deviceTypes | Array<string> | Yes | No | An array of supported device types. |
| abilityInfo | Array<AbilityInfo> | Yes | No | Ability information. |
| moduleName | string | Yes | No | Module name. |
| mainAbilityName | string | Yes | No | Name of the entrance ability. |
| installationFree | boolean | Yes | No | When installation-free is supported. |
| mainElementName | string | Yes| No| Information about the entry ability.|
| mainElementName | string | Yes| No| Information about the entry ability. |
## AppVersionInfo<sup>7+</sup>
| Name | Type| Readable | Writable | Description|
| Name | Type| Readable | Writable | Description |
| ------ | ------ | ------| ------ | ------ |
| appName | string | Yes | No | Module name. |
| versionCode | number | Yes | No | Module description. |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册