提交 77887b60 编写于 作者: G Gloria 提交者: wusongqing

fixed 4ded4b6c from https://gitee.com/wusongqing/docs/pulls/15083

Update docs against 14342+14253+14188+13998

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 bef315d6
...@@ -14,7 +14,7 @@ The ParticleAbility module is used to perform operations on abilities of the Dat ...@@ -14,7 +14,7 @@ The ParticleAbility module is used to perform operations on abilities of the Dat
## Modules to Import ## Modules to Import
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
``` ```
## particleAbility.startAbility ## particleAbility.startAbility
...@@ -25,7 +25,7 @@ Starts a ParticleAbility. This API uses an asynchronous callback to return the r ...@@ -25,7 +25,7 @@ Starts a ParticleAbility. This API uses an asynchronous callback to return the r
Observe the following when using this API: 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. - 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.
- If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission. - If **visible** of the target ability is **false**, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md). - For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
...@@ -40,27 +40,27 @@ Observe the following when using this API: ...@@ -40,27 +40,27 @@ Observe the following when using this API:
**Example** **Example**
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
import wantConstant from '@ohos.ability.wantConstant' import wantConstant from '@ohos.ability.wantConstant';
particleAbility.startAbility( particleAbility.startAbility(
{ {
want: want:
{ {
action: "action.system.home", action: 'action.system.home',
entities: ["entity.system.home"], entities: ['entity.system.home'],
type: "MIMETYPE", type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "", deviceId: '',
bundleName: "com.example.Data", bundleName: 'com.example.Data',
abilityName: "EntryAbility", abilityName: 'com.example.Data.MainAbility',
uri: "" uri: ''
}, },
}, },
(error, result) => { (error, result) => {
console.log('particleAbility startAbility errCode:' + error + 'result:' + result) console.log('particleAbility startAbility errCode:' + error + 'result:' + result);
}, },
) );
``` ```
## particleAbility.startAbility ## particleAbility.startAbility
...@@ -71,7 +71,7 @@ Starts a ParticleAbility. This API uses a promise to return the result. ...@@ -71,7 +71,7 @@ Starts a ParticleAbility. This API uses a promise to return the result.
Observe the following when using this API: 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. - 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.
- If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission. - If **visible** of the target ability is **false**, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md). - For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
...@@ -91,25 +91,25 @@ Observe the following when using this API: ...@@ -91,25 +91,25 @@ Observe the following when using this API:
**Example** **Example**
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
import wantConstant from '@ohos.ability.wantConstant' import wantConstant from '@ohos.ability.wantConstant';
particleAbility.startAbility( particleAbility.startAbility(
{ {
want: want:
{ {
action: "action.system.home", action: 'action.system.home',
entities: ["entity.system.home"], entities: ['entity.system.home'],
type: "MIMETYPE", type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "", deviceId: '',
bundleName: "com.example.Data", bundleName: 'com.example.Data',
abilityName: "EntryAbility", abilityName: 'com.example. Data.MainAbility',
uri: "" uri: ''
}, },
}, },
).then((data) => { ).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 ...@@ -130,13 +130,13 @@ Terminates this ParticleAbility. This API uses an asynchronous callback to retur
**Example** **Example**
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
particleAbility.terminateSelf( particleAbility.terminateSelf(
(error, result) => { (error, result) => {
console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result) console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result);
} }
) );
``` ```
## particleAbility.terminateSelf ## particleAbility.terminateSelf
...@@ -156,10 +156,10 @@ Terminates this ParticleAbility. This API uses a promise to return the result. ...@@ -156,10 +156,10 @@ Terminates this ParticleAbility. This API uses a promise to return the result.
**Example** **Example**
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
particleAbility.terminateSelf().then((data) => { particleAbility.terminateSelf().then((data) => {
console.info("particleAbility terminateSelf"); console.info('particleAbility terminateSelf');
}); });
``` ```
...@@ -171,12 +171,6 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper ...@@ -171,12 +171,6 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper
Obtains a **dataAbilityHelper** object. Obtains a **dataAbilityHelper** object.
Observe the following when using this API:
- To access a DataAbility of another application, the target application must be configured with associated startup (**AssociateWakeUp** set to **true**).
- If an application running in the background needs to call this API to access a DataAbility, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters** **Parameters**
...@@ -194,10 +188,10 @@ Observe the following when using this API: ...@@ -194,10 +188,10 @@ Observe the following when using this API:
**Example** **Example**
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
var uri = ""; let uri = '';
particleAbility.acquireDataAbilityHelper(uri) particleAbility.acquireDataAbilityHelper(uri);
``` ```
...@@ -228,17 +222,17 @@ import wantAgent from '@ohos.wantAgent'; ...@@ -228,17 +222,17 @@ import wantAgent from '@ohos.wantAgent';
function callback(err, data) { function callback(err, data) {
if (err) { if (err) {
console.error("Operation failed cause: " + JSON.stringify(err)); console.error('Operation failed cause: ' + JSON.stringify(err));
} else { } else {
console.info("Operation succeeded"); console.info('Operation succeeded');
} }
} }
let wantAgentInfo = { let wantAgentInfo = {
wants: [ wants: [
{ {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility" abilityName: 'com.example.myapplication.MainAbility'
} }
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
...@@ -248,8 +242,8 @@ let wantAgentInfo = { ...@@ -248,8 +242,8 @@ let wantAgentInfo = {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
let basicContent = { let basicContent = {
title: "title", title: 'title',
text: "text" text: 'text'
}; };
let notificationContent = { let notificationContent = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -298,8 +292,8 @@ import wantAgent from '@ohos.wantAgent'; ...@@ -298,8 +292,8 @@ import wantAgent from '@ohos.wantAgent';
let wantAgentInfo = { let wantAgentInfo = {
wants: [ wants: [
{ {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility" abilityName: 'com.example.myapplication.MainAbility'
} }
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
...@@ -309,8 +303,8 @@ let wantAgentInfo = { ...@@ -309,8 +303,8 @@ let wantAgentInfo = {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
let basicContent = { let basicContent = {
title: "title", title: 'title',
text: "text" text: 'text'
}; };
let notificationContent = { let notificationContent = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -322,9 +316,9 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { ...@@ -322,9 +316,9 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
}; };
let id = 1; let id = 1;
particleAbility.startBackgroundRunning(id, request).then(() => { particleAbility.startBackgroundRunning(id, request).then(() => {
console.info("Operation succeeded"); console.info('Operation succeeded');
}).catch((err) => { }).catch((err) => {
console.error("Operation failed cause: " + JSON.stringify(err)); console.error('Operation failed cause: ' + JSON.stringify(err));
}); });
}); });
...@@ -351,9 +345,9 @@ import particleAbility from '@ohos.ability.particleAbility'; ...@@ -351,9 +345,9 @@ import particleAbility from '@ohos.ability.particleAbility';
function callback(err, data) { function callback(err, data) {
if (err) { if (err) {
console.error("Operation failed cause: " + JSON.stringify(err)); console.error('Operation failed cause: ' + JSON.stringify(err));
} else { } else {
console.info("Operation succeeded"); console.info('Operation succeeded');
} }
} }
...@@ -381,9 +375,9 @@ Requests to cancel a continuous task from the system. This API uses a promise to ...@@ -381,9 +375,9 @@ Requests to cancel a continuous task from the system. This API uses a promise to
import particleAbility from '@ohos.ability.particleAbility'; import particleAbility from '@ohos.ability.particleAbility';
particleAbility.cancelBackgroundRunning().then(() => { particleAbility.cancelBackgroundRunning().then(() => {
console.info("Operation succeeded"); console.info('Operation succeeded');
}).catch((err) => { }).catch((err) => {
console.error("Operation failed cause: " + JSON.stringify(err)); console.error('Operation failed cause: ' + JSON.stringify(err));
}); });
``` ```
...@@ -394,12 +388,6 @@ connectAbility(request: Want, options:ConnectOptions): number ...@@ -394,12 +388,6 @@ connectAbility(request: Want, options:ConnectOptions): number
Connects this ability to a specific ServiceAbility. Connects this ability to a specific ServiceAbility.
Observe the following when using this API:
- To connect to a ServiceAbility of another application, the target application must be configured with associated startup (**AssociateWakeUp** set to **true**)..
- If an application running in the background needs to call this API to connect to a ServiceAbility, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters** **Parameters**
...@@ -413,25 +401,25 @@ Observe the following when using this API: ...@@ -413,25 +401,25 @@ Observe the following when using this API:
**Example** **Example**
```ts ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc' import rpc from '@ohos.rpc';
function onConnectCallback(element, remote) { 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) { function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId);
} }
function onFailedCallback(code) { 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", bundleName: 'com.ix.ServiceAbility',
abilityName: "ServiceAbilityA", abilityName: 'ServiceAbilityA',
}, },
{ {
onConnect: onConnectCallback, onConnect: onConnectCallback,
...@@ -441,11 +429,10 @@ var connId = particleAbility.connectAbility( ...@@ -441,11 +429,10 @@ var connId = particleAbility.connectAbility(
); );
particleAbility.disconnectAbility(connId).then((data) => { particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data); console.log(' data: ' + data);
}).catch((error) => { }).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code) console.log('particleAbilityTest result errCode : ' + error.code);
}); });
``` ```
## particleAbility.disconnectAbility ## particleAbility.disconnectAbility
...@@ -473,17 +460,17 @@ function onConnectCallback(element, remote) { ...@@ -473,17 +460,17 @@ function onConnectCallback(element, remote) {
} }
function onDisconnectCallback(element) { function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId);
} }
function onFailedCallback(code) { 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", bundleName: 'com.ix.ServiceAbility',
abilityName: "ServiceAbilityA", abilityName: 'ServiceAbilityA',
}, },
{ {
onConnect: onConnectCallback, onConnect: onConnectCallback,
...@@ -491,10 +478,10 @@ var connId = particleAbility.connectAbility( ...@@ -491,10 +478,10 @@ var connId = particleAbility.connectAbility(
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
); );
var result = particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data); particleAbility.disconnectAbility(connId, (err) => {
}).catch((error) => { console.log('particleAbilityTest disconnectAbility err====>'
console.log('particleAbilityTest result errCode : ' + error.code) + ('json err=') + JSON.stringify(err));
}); });
``` ```
...@@ -524,17 +511,17 @@ function onConnectCallback(element, remote) { ...@@ -524,17 +511,17 @@ function onConnectCallback(element, remote) {
} }
function onDisconnectCallback(element) { function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId);
} }
function onFailedCallback(code) { 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", bundleName: 'com.ix.ServiceAbility',
abilityName: "ServiceAbilityA", abilityName: 'ServiceAbilityA',
}, },
{ {
onConnect: onConnectCallback, onConnect: onConnectCallback,
...@@ -544,9 +531,9 @@ var connId = particleAbility.connectAbility( ...@@ -544,9 +531,9 @@ var connId = particleAbility.connectAbility(
); );
particleAbility.disconnectAbility(connId).then((data) => { particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data); console.log(' data: ' + data);
}).catch((error) => { }).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.
先完成此消息的编辑!
想要评论请 注册