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

!5555 翻译完成:5114 Fix abilityName error of ability

Merge pull request !5555 from wusongqing/TR5114
# Context Module
> **NOTE**<br/>
> **NOTE**
>
> 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.
> The APIs of this module can be used only in the FA model.
## Modules to Import
......@@ -834,7 +836,7 @@ Obtains information of the current ability. This API uses an asynchronous callba
| 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**
......@@ -886,7 +888,7 @@ Obtains the context of the application.
| Type | Description |
| --------- |------ |
| Context |Application context.|
| Context | Application context.|
**Example**
......@@ -928,14 +930,14 @@ Describes the HAP module information.
| labelId | number | Yes | No | Module label ID. |
| iconId | number | Yes | No | Module icon ID. |
| backgroundImg | string | Yes | No | Module background image. |
| supportedModes | number | Yes | No | Modes supported by the module. |
| supportedModes | number | Yes | No | Running 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.|
| deviceTypes | Array<string> | Yes | No | Device types supported by the module.|
| 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.|
| mainAbilityName | string | Yes | No | Name of the main ability. |
| installationFree | boolean | Yes | No | Whether installation-free is supported. |
| mainElementName | string | Yes| No| Information about the main ability.|
## AppVersionInfo<sup>7+</sup>
......
# AbilityContext
> **NOTE**<br/>
> **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.
Implements the ability context. This module is inherited from **Context**.
......@@ -55,7 +57,7 @@ Starts an ability. This API uses a callback to return the result.
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
"abilityName": "com.extreme.test.MainAbility"
"abilityName": "MainAbility"
};
this.context.startAbility(want, (error) => {
console.log("error.code = " + error.code)
......@@ -85,7 +87,7 @@ Starts an ability. This API uses a callback to return the result.
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
"abilityName": "com.extreme.test.MainAbility"
"abilityName": "MainAbility"
};
var options = {
windowMode: 0,
......@@ -123,7 +125,7 @@ Starts an ability. This API uses a promise to return the result.
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
"abilityName": "com.extreme.test.MainAbility"
"abilityName": "MainAbility"
};
var options = {
windowMode: 0,
......@@ -374,7 +376,7 @@ Obtains the caller interface of the specified ability, and if the specified abil
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
abilityName: "com.example.myservice.MainAbility",
abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
......
# Ability
> **NOTE**<br>
> **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.
Manages the ability lifecycle and context.
......@@ -347,7 +349,7 @@ Sends sequenceable data to the target ability.
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
abilityName: "com.example.myservice.MainAbility",
abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
......@@ -420,7 +422,7 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
abilityName: "com.example.myservice.MainAbility",
abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
......@@ -459,7 +461,7 @@ Releases the caller interface of the target ability.
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
abilityName: "com.example.myservice.MainAbility",
abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
......@@ -500,7 +502,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
abilityName: "com.example.myservice.MainAbility",
abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
......
......@@ -923,7 +923,7 @@ Enumerates operation types of the Data ability.
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Name | Description |
| Name | Value | Description |
| ------------------------------------ | ---------- | ---------------------------------------- |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. |
......
# ServiceExtensionContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **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.
Implements the context that provides the capabilities and APIs of **ServiceExtension**. This class is inherited from **ExtensionContext**.
## Modules to Import
```
import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
```
## startAbility
......@@ -25,13 +31,18 @@ Starts an ability. This API uses a callback to return the result.
**Example**
```js
import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
class MainAbility extends ExtensionContext {
onWindowStageCreate(windowStage) {
let want = {
"bundleName": "com.example.myapp",
"abilityName": "com.example.myapp.MyAbility"
};
"abilityName": "MyAbility"};
this.context.startAbility(want, (err) => {
console.log('startAbility result:' + JSON.stringfy(err));
console.log('startAbility result:' + JSON.stringify(err));
});
}
}
```
......@@ -58,15 +69,22 @@ Starts an ability. This API uses a promise to return the result.
**Example**
```js
import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
class MainAbility extends ExtensionContext {
onWindowStageCreate(windowStage) {
let want = {
"bundleName": "com.example.myapp",
"abilityName": "com.example.myapp.MyAbility"
"abilityName": "MyAbility"
};
this.context.startAbility(want).then((data) => {
console.log('success:' + JSON.stringfy(data));
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
console.log('failed:' + JSON.stringify(error));
});
}
}
```
......@@ -87,9 +105,16 @@ Terminates this ability. This API uses a callback to return the result.
**Example**
```js
import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
class MainAbility extends ExtensionContext {
onWindowStageCreate(windowStage) {
this.context.terminateSelf((err) => {
console.log('terminateSelf result:' + JSON.stringfy(err));
console.log('terminateSelf result:' + JSON.stringify(err));
});
}
}
```
......@@ -110,11 +135,17 @@ Terminates this ability. This API uses a promise to return the result.
**Example**
```js
this.context.terminateSelf(want).then((data) => {
console.log('success:' + JSON.stringfy(data));
import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
class MainAbility extends ExtensionContext {
onWindowStageCreate(windowStage) {
this.context.terminateSelf().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
console.log('failed:' + JSON.stringify(error));
});
}
}
```
......@@ -144,7 +175,7 @@ Connects this ability to a Service ability.
```js
let want = {
"bundleName": "com.example.myapp",
"abilityName": "com.example.myapp.MyAbility"
"abilityName": "MyAbility"
};
let options = {
onConnect: function(elementName, proxy) {},
......@@ -173,9 +204,18 @@ Disconnects this ability from the Service ability. This API uses a callback to r
**Example**
```js
this.context.disconnectAbility(connection, (err) => { // connection is the return value of connectAbility.
console.log('terminateSelf result:' + JSON.stringfy(err));
import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
class MainAbility extends ExtensionContext {
onWindowStageCreate(windowStage) {
let connection=1
this.context.disconnectAbility(connection, (err) => {
// connection is the return value of connectAbility.
console.log('terminateSelf result:' + JSON.stringify(err));
});
}
}
```
......@@ -202,11 +242,18 @@ Disconnects this ability from the Service ability. This API uses a promise to re
**Example**
```js
import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
class MainAbility extends ExtensionContext {
onWindowStageCreate(windowStage) {
let connection=1
this.context.disconnectAbility(connection).then((data) => { // connection is the return value of connectAbility.
console.log('success:' + JSON.stringfy(data));
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
console.log('failed:' + JSON.stringify(error));
});
}
}
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册