提交 2c30e95b 编写于 作者: G Gloria

Update docs against 13992+14771+14303+14276+14205

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 459882dd
......@@ -41,24 +41,24 @@ Observe the following when using this API:
```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
import wantConstant from '@ohos.app.ability.wantConstant';
featureAbility.startAbility(
{
want:
{
action: "",
entities: [""],
type: "",
action: '',
entities: [''],
type: '',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "",
bundleName: "com.example.myapplication",
deviceId: '',
bundleName: 'com.example.myapplication',
/* In the FA model, abilityName consists of package and ability names. */
abilityName: "com.example.myapplication.secondAbility",
uri: ""
abilityName: 'com.example.myapplication.secondAbility',
uri: ''
},
},
(err, data) => {
console.info("startAbility err: " + JSON.stringify(err) + "data: " + JSON.stringify(data));
console.info('startAbility err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
}
);
```
......@@ -94,24 +94,24 @@ Observe the following when using this API:
```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
import wantConstant from '@ohos.app.ability.wantConstant';
featureAbility.startAbility(
{
want:
{
action: "action.system.home",
entities: ["entity.system.home"],
type: "MIMETYPE",
action: 'action.system.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "",
bundleName: "com.example.myapplication",
deviceId: '',
bundleName: 'com.example.myapplication',
/* In the FA model, abilityName consists of package and ability names. */
abilityName: "com.example.myapplication.secondAbility",
uri: ""
abilityName: 'com.example.myapplication.secondAbility',
uri: ''
},
}
).then((data) => {
console.info("startAbility data: " + JSON.stringify(data));
console.info('startAbility data: ${JSON.stringify(data)}');
});
```
......@@ -145,8 +145,8 @@ Observe the following when using this API:
```ts
import featureAbility from '@ohos.ability.featureAbility';
var dataAbilityHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(
'dataability:///com.example.DataAbility'
);
```
......@@ -154,7 +154,10 @@ var dataAbilityHelper = featureAbility.acquireDataAbilityHelper(
startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\<AbilityResult>): void
Starts an ability. After the ability is started, you can call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability and return the result to the caller. If an exception occurs, for example, the ability is killed, exception information is returned to the caller. This API uses an asynchronous callback to return the result.
Starts an ability. This API uses an asynchronous callback to return the result when the ability is terminated. The following situations may be possible for a started ability:
- Normally, you can call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability. The result is returned to the caller.
- If an exception occurs, for example, the ability is killed, an exception message, in which **resultCode** is **-1**, is returned to the caller.
- If different applications call this API to start an ability that uses the sington mode and then call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability, the normal result is returned to the last caller, and an exception message, in which **resultCode** is **-1**, is returned to others.
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
......@@ -174,24 +177,24 @@ Observe the following when using this API:
```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
import wantConstant from '@ohos.app.ability.wantConstant';
featureAbility.startAbilityForResult(
{
want:
{
action: "action.system.home",
entities: ["entity.system.home"],
type: "MIMETYPE",
action: 'action.system.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "",
bundleName: "com.example.myapplication",
deviceId: '',
bundleName: 'com.example.myapplication',
/* In the FA model, abilityName consists of package and ability names. */
abilityName: "com.example.myapplication.secondAbility",
uri:""
abilityName: 'com.example.myapplication.secondAbility',
uri:''
},
},
(err, data) => {
console.info("startAbilityForResult err: " + JSON.stringify(err) + "data: " + JSON.stringify(data));
console.info('startAbilityForResult err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
}
);
```
......@@ -200,7 +203,10 @@ featureAbility.startAbilityForResult(
startAbilityForResult(parameter: StartAbilityParameter): Promise\<AbilityResult>
Starts an ability. After the ability is started, you can call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability and return the result to the caller. If an exception occurs, for example, the ability is killed, exception information is returned to the caller. This API uses a promise to return the result.
Starts an ability. This API uses a promise to return the result when the ability is terminated. The following situations may be possible to an ability after it is started:
- Normally, you can call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability. The result is returned to the caller.
- If an exception occurs, for example, the ability is killed, an exception message, in which **resultCode** is **-1**, is returned to the caller.
- If different applications call this API to start an ability that uses the sington mode and then call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability, the normal result is returned to the last caller, and an exception message, in which **resultCode** is **-1**, is returned to others.
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
......@@ -225,35 +231,35 @@ Observe the following when using this API:
```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
import wantConstant from '@ohos.app.ability.wantConstant';
featureAbility.startAbilityForResult(
{
want:
{
action: "action.system.home",
entities: ["entity.system.home"],
type: "MIMETYPE",
action: 'action.system.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "",
bundleName: "com.example.myapplication",
deviceId: '',
bundleName: 'com.example.myapplication',
/* In the FA model, abilityName consists of package and ability names. */
abilityName: "com.example.myapplication.secondAbility",
uri:"",
abilityName: 'com.example.myapplication.secondAbility',
uri:'',
parameters:
{
mykey0: 1111,
mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]",
mykey3: "xxxxxxxxxxxxxxxxxxxxxx",
mykey2: '[1, 2, 3]',
mykey3: 'xxxxxxxxxxxxxxxxxxxxxx',
mykey4: [1, 15],
mykey5: [false, true, false],
mykey6: ["aaaaaa", "bbbbb", "ccccccccccc"],
mykey6: ['aaaaaa', 'bbbbb', 'ccccccccccc'],
mykey7: true,
},
},
},
).then((data) => {
console.info("startAbilityForResult data: " + JSON.stringify(data));
console.info('startAbilityForResult data: ${JSON.stringify(data)}');
});
```
......@@ -276,35 +282,35 @@ Terminates this ability. If the ability is started by calling [startAbilityForRe
```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
import wantConstant from '@ohos.app.ability.wantConstant';
featureAbility.terminateSelfWithResult(
{
resultCode: 1,
want:
{
action: "action.system.home",
entities: ["entity.system.home"],
type: "MIMETYPE",
action: 'action.system.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "",
bundleName: "com.example.myapplication",
deviceId: '',
bundleName: 'com.example.myapplication',
/* In the FA model, abilityName consists of package and ability names. */
abilityName: "com.example.myapplication.secondAbility",
uri:"",
abilityName: 'com.example.myapplication.secondAbility',
uri:'',
parameters: {
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]",
mykey3: "ssssssssssssssssssssssssss",
mykey2: '[1, 2, 3]',
mykey3: 'ssssssssssssssssssssssssss',
mykey4: [1, 15],
mykey5: [false, true, false],
mykey6: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
mykey6: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
mykey7: true,
}
},
},
(err) => {
console.info("err: " + JSON.stringify(err))
console.error('err: ${JSON.stringify(err)}');
}
);
```
......@@ -333,35 +339,35 @@ Terminates this ability. If the ability is started by calling [startAbilityForRe
```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
import wantConstant from '@ohos.app.ability.wantConstant';
featureAbility.terminateSelfWithResult(
{
resultCode: 1,
want:
{
action: "action.system.home",
entities: ["entity.system.home"],
type: "MIMETYPE",
action: 'action.system.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "",
bundleName: "com.example.myapplication",
deviceId: '',
bundleName: 'com.example.myapplication',
/* In the FA model, abilityName consists of package and ability names. */
abilityName: "com.example.myapplication.secondAbility",
uri:"",
abilityName: 'com.example.myapplication.secondAbility',
uri:'',
parameters: {
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]",
mykey3: "ssssssssssssssssssssssssss",
mykey2: '[1, 2, 3]',
mykey3: 'ssssssssssssssssssssssssss',
mykey4: [1, 15],
mykey5: [false, true, false],
mykey6: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
mykey6: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
mykey7: true,
}
},
}
).then((data) => {
console.info("==========================>terminateSelfWithResult=======================>");
console.info('==========================>terminateSelfWithResult=======================>');
});
```
......@@ -384,7 +390,7 @@ Checks whether the main window of this ability has the focus. This API uses an a
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.hasWindowFocus((err, data) => {
console.info("hasWindowFocus err: " + JSON.stringify(err) + "data: " + JSON.stringify(data));
console.info('hasWindowFocus err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
});
```
......@@ -407,7 +413,7 @@ Checks whether the main window of this ability has the focus. This API uses a pr
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.hasWindowFocus().then((data) => {
console.info("hasWindowFocus data: " + JSON.stringify(data));
console.info('hasWindowFocus data: ${JSON.stringify(data)}');
});
```
......@@ -430,7 +436,7 @@ Obtains the Want corresponding to the ability to start. This API uses an asynchr
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant((err, data) => {
console.info("getWant err: " + JSON.stringify(err) + "data: " + JSON.stringify(data));
console.info('getWant err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
});
```
......@@ -453,7 +459,7 @@ Obtains the Want corresponding to the ability to start. This API uses a promise
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant().then((data) => {
console.info("getWant data: " + JSON.stringify(data));
console.info('getWant data: ${JSON.stringify(data)}');
});
```
......@@ -475,9 +481,9 @@ Obtains the application context.
```ts
import featureAbility from '@ohos.ability.featureAbility';
var context = featureAbility.getContext()
let context = featureAbility.getContext();
context.getBundleName((err, data) => {
console.info("getBundleName err: " + JSON.stringify(err) + "data: " + JSON.stringify(data));
console.info('getBundleName err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
});
```
......@@ -501,7 +507,7 @@ Terminates this ability. This API uses an asynchronous callback to return the re
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf(
(err) => {
console.info("err: " + JSON.stringify(err))
console.error('err: ${JSON.stringify(err)}');
}
)
```
......@@ -525,7 +531,7 @@ Terminates this ability. This API uses a promise to return the result.
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf().then((data) => {
console.info("==========================>terminateSelf=======================>");
console.info('==========================>terminateSelf=======================>');
});
```
......@@ -562,19 +568,19 @@ Observe the following when using this API:
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
console.log('ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}');
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}')
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
console.log('featureAbilityTest ConnectAbility onFailed errCode : ${code}')
}
var connectId = featureAbility.connectAbility(
let connectId = featureAbility.connectAbility(
{
deviceId: "",
bundleName: "com.ix.ServiceAbility",
abilityName: "com.ix.ServiceAbility.ServiceAbilityA",
deviceId: '',
bundleName: 'com.ix.ServiceAbility',
abilityName: 'com.ix.ServiceAbility.ServiceAbilityA',
},
{
onConnect: onConnectCallback,
......@@ -605,18 +611,18 @@ Disconnects this ability from a specific ServiceAbility. This API uses an asynch
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
console.log('ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}');
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
console.log('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
}
var connectId = featureAbility.connectAbility(
let connectId = featureAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "com.ix.ServiceAbility.ServiceAbilityA",
bundleName: 'com.ix.ServiceAbility',
abilityName: 'com.ix.ServiceAbility.ServiceAbilityA',
},
{
onConnect: onConnectCallback,
......@@ -624,11 +630,10 @@ var connectId = featureAbility.connectAbility(
onFailed: onFailedCallback,
},
);
var result = featureAbility.disconnectAbility(connectId,
(error) => {
console.log('featureAbilityTest DisConnectJsSameBundleName result errCode : ' + error.code)
},
);
featureAbility.disconnectAbility(connectId, (err) => {
console.error('featureAbilityTest disconnectAbility err: ${JSON.stringify(err)}');
});
```
## featureAbility.disconnectAbility<sup>7+</sup>
......@@ -657,18 +662,18 @@ Disconnects this ability from a specific ServiceAbility. This API uses a promise
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
console.log('ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}');
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
console.log('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
}
var connectId = featureAbility.connectAbility(
let connectId = featureAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "com.ix.ServiceAbility.ServiceAbilityA",
bundleName: 'com.ix.ServiceAbility',
abilityName: 'com.ix.ServiceAbility.ServiceAbilityA',
},
{
onConnect: onConnectCallback,
......@@ -678,9 +683,9 @@ var connectId = featureAbility.connectAbility(
);
featureAbility.disconnectAbility(connectId).then((data) => {
console.log('data : ' + data);
console.log('data: ${data)}';
}).catch((error)=>{
console.log('featureAbilityTest result errCode : ' + error.code);
console.error('featureAbilityTest result errCode : ${error.code}');
});
```
......@@ -703,7 +708,7 @@ Obtains the window corresponding to this ability. This API uses an asynchronous
```ts
featureAbility.getWindow((err, data) => {
console.info("getWindow err: " + JSON.stringify(err) + "data: " + typeof(data));
console.info('getWindow err: ${JSON.stringify(err)}, data: ${typeof(data)}');
});
```
......@@ -725,7 +730,7 @@ Obtains the window corresponding to this ability. This API uses a promise to ret
```ts
featureAbility.getWindow().then((data) => {
console.info("getWindow data: " + typeof(data));
console.info('getWindow data: ${typeof(data)}');
});
```
......@@ -745,8 +750,8 @@ featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED
| ---------------------------------------- | ---- | ---------------------------------------- |
| WINDOW_MODE_UNDEFINED<sup>7+</sup> | 0 | The PageAbility is in an undefined window display mode.|
| WINDOW_MODE_FULLSCREEN<sup>7+</sup> | 1 | The PageAbility is in full screen mode. |
| WINDOW_MODE_SPLIT_PRIMARY<sup>7+</sup> | 100 | The PageAbility is displayed in the primary window when it is in split-screen mode.|
| WINDOW_MODE_SPLIT_SECONDARY<sup>7+</sup> | 101 | The PageAbility is displayed in the secondary window when it is in split-screen mode.|
| WINDOW_MODE_SPLIT_PRIMARY<sup>7+</sup> | 100 | The left screen in horizontal direction or the upper screen in vertical direction is the primary window.|
| WINDOW_MODE_SPLIT_SECONDARY<sup>7+</sup> | 101 | The right screen in horizontal direction or the lower screen in vertical direction is the secondary window.|
| WINDOW_MODE_FLOATING<sup>7+</sup> | 102 | The PageAbility is displayed in floating window mode.|
......@@ -766,9 +771,9 @@ featureAbility.AbilityStartSetting.BOUNDS_KEY
| Name | Value | Description |
| ---------------------------- | --------------- | ---------------------------------------- |
| BOUNDS_KEY<sup>7+</sup> | "abilityBounds" | Ability window size.|
| WINDOW_MODE_KEY<sup>7+</sup> | "windowMode" | Ability window display mode.|
| DISPLAY_ID_KEY<sup>7+</sup> | "displayId" | Display device ID.|
| BOUNDS_KEY<sup>7+</sup> | 'abilityBounds' | Ability window size.|
| WINDOW_MODE_KEY<sup>7+</sup> | 'windowMode' | Ability window display mode.|
| DISPLAY_ID_KEY<sup>7+</sup> | 'displayId' | Display device ID.|
## ErrorCode
......
......@@ -14,7 +14,7 @@ The ParticleAbility module is used to perform operations on abilities of the Dat
## Modules to Import
```ts
import particleAbility from '@ohos.ability.particleAbility'
import particleAbility from '@ohos.ability.particleAbility';
```
## particleAbility.startAbility
......@@ -40,27 +40,27 @@ Observe the following when using this API:
**Example**
```ts
import particleAbility from '@ohos.ability.particleAbility'
import wantConstant from '@ohos.ability.wantConstant'
import particleAbility from '@ohos.ability.particleAbility';
import wantConstant from '@ohos.ability.wantConstant';
particleAbility.startAbility(
{
want:
{
action: "action.system.home",
entities: ["entity.system.home"],
type: "MIMETYPE",
action: 'action.system.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "",
bundleName: "com.example.Data",
abilityName: "EntryAbility",
uri: ""
deviceId: '',
bundleName: 'com.example.Data',
abilityName: 'EntryAbility',
uri: ''
},
},
(error, result) => {
console.log('particleAbility startAbility errCode:' + error + 'result:' + result)
console.error('particleAbility startAbility errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}');
},
)
);
```
## particleAbility.startAbility
......@@ -91,25 +91,25 @@ Observe the following when using this API:
**Example**
```ts
import particleAbility from '@ohos.ability.particleAbility'
import wantConstant from '@ohos.ability.wantConstant'
import particleAbility from '@ohos.ability.particleAbility';
import wantConstant from '@ohos.ability.wantConstant';
particleAbility.startAbility(
{
want:
{
action: "action.system.home",
entities: ["entity.system.home"],
type: "MIMETYPE",
action: 'action.system.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "",
bundleName: "com.example.Data",
abilityName: "EntryAbility",
uri: ""
deviceId: '',
bundleName: 'com.example.Data',
abilityName: 'EntryAbility',
uri: ''
},
},
).then((data) => {
console.info("particleAbility startAbility");
console.info('particleAbility startAbility');
});
```
......@@ -130,13 +130,13 @@ Terminates this ParticleAbility. This API uses an asynchronous callback to retur
**Example**
```ts
import particleAbility from '@ohos.ability.particleAbility'
import particleAbility from '@ohos.ability.particleAbility';
particleAbility.terminateSelf(
(error, result) => {
console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result)
console.log('particleAbility terminateSelf errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}');
}
)
);
```
## particleAbility.terminateSelf
......@@ -156,10 +156,10 @@ Terminates this ParticleAbility. This API uses a promise to return the result.
**Example**
```ts
import particleAbility from '@ohos.ability.particleAbility'
import particleAbility from '@ohos.ability.particleAbility';
particleAbility.terminateSelf().then((data) => {
console.info("particleAbility terminateSelf");
console.info('particleAbility terminateSelf');
});
```
......@@ -194,10 +194,10 @@ Observe the following when using this API:
**Example**
```ts
import particleAbility from '@ohos.ability.particleAbility'
import particleAbility from '@ohos.ability.particleAbility';
var uri = "";
particleAbility.acquireDataAbilityHelper(uri)
let uri = '';
particleAbility.acquireDataAbilityHelper(uri);
```
......@@ -228,17 +228,17 @@ import wantAgent from '@ohos.app.ability.wantAgent';
function callback(err, data) {
if (err) {
console.error("Operation failed cause: " + JSON.stringify(err));
console.error('Operation failed cause: ${JSON.stringify(err)}');
} else {
console.info("Operation succeeded");
console.info('Operation succeeded');
}
}
let wantAgentInfo = {
wants: [
{
bundleName: "com.example.myapplication",
abilityName: "EntryAbility"
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
}
],
operationType: wantAgent.OperationType.START_ABILITY,
......@@ -248,8 +248,8 @@ let wantAgentInfo = {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
let basicContent = {
title: "title",
text: "text"
title: 'title',
text: 'text'
};
let notificationContent = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
......@@ -298,8 +298,8 @@ import wantAgent from '@ohos.app.ability.wantAgent';
let wantAgentInfo = {
wants: [
{
bundleName: "com.example.myapplication",
abilityName: "EntryAbility"
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
}
],
operationType: wantAgent.OperationType.START_ABILITY,
......@@ -309,8 +309,8 @@ let wantAgentInfo = {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
let basicContent = {
title: "title",
text: "text"
title: 'title',
text: 'text'
};
let notificationContent = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
......@@ -322,9 +322,9 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
};
let id = 1;
particleAbility.startBackgroundRunning(id, request).then(() => {
console.info("Operation succeeded");
console.info('Operation succeeded');
}).catch((err) => {
console.error("Operation failed cause: " + JSON.stringify(err));
console.error('Operation failed cause: ${JSON.stringify(err)}');
});
});
......@@ -351,9 +351,9 @@ import particleAbility from '@ohos.ability.particleAbility';
function callback(err, data) {
if (err) {
console.error("Operation failed cause: " + JSON.stringify(err));
console.error('Operation failed cause: ${JSON.stringify(err)}');
} else {
console.info("Operation succeeded");
console.info('Operation succeeded');
}
}
......@@ -381,9 +381,9 @@ Requests to cancel a continuous task from the system. This API uses a promise to
import particleAbility from '@ohos.ability.particleAbility';
particleAbility.cancelBackgroundRunning().then(() => {
console.info("Operation succeeded");
console.info('Operation succeeded');
}).catch((err) => {
console.error("Operation failed cause: " + JSON.stringify(err));
console.error('Operation failed cause: ${JSON.stringify(err)}');
});
```
......@@ -413,25 +413,25 @@ Observe the following when using this API:
**Example**
```ts
import particleAbility from '@ohos.ability.particleAbility'
import rpc from '@ohos.rpc'
import particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc';
function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
console.log('ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}');
}
function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
console.log('particleAbilityTest ConnectAbility onFailed errCode : ${code}');
}
var connId = particleAbility.connectAbility(
let connId = particleAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
bundleName: 'com.ix.ServiceAbility',
abilityName: 'ServiceAbilityA',
},
{
onConnect: onConnectCallback,
......@@ -441,9 +441,9 @@ var connId = particleAbility.connectAbility(
);
particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data);
console.log(' data: ${data}');
}).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code)
console.log('particleAbilityTest result errCode : ${error.code}');
});
```
......@@ -468,21 +468,21 @@ import particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc';
function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
console.log('ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}');
}
function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
console.log('particleAbilityTest ConnectAbility onFailed errCode : ${code}');
}
var connId = particleAbility.connectAbility(
let connId = particleAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
bundleName: 'com.ix.ServiceAbility',
abilityName: 'ServiceAbilityA',
},
{
onConnect: onConnectCallback,
......@@ -492,8 +492,7 @@ var connId = particleAbility.connectAbility(
);
particleAbility.disconnectAbility(connId, (err) => {
console.log("particleAbilityTest disconnectAbility err====>"
+ ("json err=") + JSON.stringify(err));
console.log('particleAbilityTest disconnectAbility err: ${JSON.stringify(err)}');
});
```
......@@ -519,21 +518,21 @@ import particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc';
function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
console.log('ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}');
}
function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
console.log('particleAbilityTest ConnectAbility onFailed errCode : ${code}');
}
var connId = particleAbility.connectAbility(
let connId = particleAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
bundleName: 'com.ix.ServiceAbility',
abilityName: 'ServiceAbilityA',
},
{
onConnect: onConnectCallback,
......@@ -543,9 +542,9 @@ var connId = particleAbility.connectAbility(
);
particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data);
console.log(' data: ${data}');
}).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code)
console.log('particleAbilityTest result errCode : ${error.code}');
});
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册