提交 3dd63e1f 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 a331e99e
...@@ -18,15 +18,16 @@ Starts an ability. This method uses a callback to return the result. ...@@ -18,15 +18,16 @@ Starts an ability. This method uses a callback to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| --------- | --------------------- | ---- | ------------------- | | --------- | --------------------- | ---- | ------------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| | parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| callback | AsyncCallback\<number> | Yes| Callback used to return the result.| | callback | AsyncCallback\<number> | Yes | Callback used to return the result. |
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import wantConstant from '@ohos.ability.wantConstant'
featureAbility.startAbility( featureAbility.startAbility(
{ {
want: want:
...@@ -34,15 +35,14 @@ featureAbility.startAbility( ...@@ -34,15 +35,14 @@ featureAbility.startAbility(
action: "", action: "",
entities: [""], entities: [""],
type: "", type: "",
flags: FLAG_AUTH_READ_URI_PERMISSION, flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "", deviceId: "",
bundleName: "com.example.startability", bundleName: "com.example.startability",
abilityName: "com.example.startability.MainAbility", abilityName: "com.example.startability.MainAbility",
uri: "" uri: ""
}, },
}, },
); );
)
``` ```
...@@ -55,14 +55,15 @@ Starts an ability. This method uses a promise to return the result. ...@@ -55,14 +55,15 @@ Starts an ability. This method uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| --------- | ----------------------------------------------- | ---- | --------------------- | | --------- | ----------------------------------------------- | ---- | --------------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| | parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import wantConstant from '@ohos.ability.wantConstant'
featureAbility.startAbility( featureAbility.startAbility(
{ {
want: want:
...@@ -70,14 +71,14 @@ featureAbility.startAbility( ...@@ -70,14 +71,14 @@ featureAbility.startAbility(
action: "action.system.home", action: "action.system.home",
entities: ["entity.system.home"], entities: ["entity.system.home"],
type: "MIMETYPE", type: "MIMETYPE",
flags: FLAG_AUTH_READ_URI_PERMISSION, flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: deviceId, deviceId: "",
bundleName: "com.example.startability", bundleName: "com.example.startability",
abilityName: "com.example.startability.MainAbility", abilityName: "com.example.startability.MainAbility",
uri: "" uri: ""
}, },
} }
).then((void) => { ).then((data) => {
console.info("==========================>startAbility=======================>"); console.info("==========================>startAbility=======================>");
}); });
``` ```
...@@ -90,13 +91,13 @@ Obtains a **dataAbilityHelper** object. ...@@ -90,13 +91,13 @@ Obtains a **dataAbilityHelper** object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ------------------------ | | ---- | ------ | ---- | ------------------------ |
| uri | string | Yes| URI of the file to open.| | uri | string | Yes | URI of the file to open.|
**Return value** **Return value**
| Type| Description| | Type | Description |
| ----------------- | -------------------------------------------- | | ----------------- | -------------------------------------------- |
| DataAbilityHelper | A utility class used to help other abilities access the Data ability.| | DataAbilityHelper | A utility class used to help other abilities access the Data ability.|
...@@ -117,15 +118,16 @@ Starts an ability. This method uses a callback to return the execution result wh ...@@ -117,15 +118,16 @@ Starts an ability. This method uses a callback to return the execution result wh
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| --------- | ----------------------------------------------- | ---- | --------------------- | | --------- | ----------------------------------------------- | ---- | --------------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| | parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes| Callback used to return the result.| | callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes | Callback used to return the result. |
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
import wantConstant from '@ohos.ability.wantConstant'
featureAbility.startAbilityForResult( featureAbility.startAbilityForResult(
{ {
want: want:
...@@ -133,7 +135,7 @@ featureAbility.startAbilityForResult( ...@@ -133,7 +135,7 @@ featureAbility.startAbilityForResult(
action: "action.system.home", action: "action.system.home",
entities: ["entity.system.home"], entities: ["entity.system.home"],
type: "MIMETYPE", type: "MIMETYPE",
flags: FLAG_AUTH_READ_URI_PERMISSION, flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "", deviceId: "",
bundleName: "com.example.featureabilitytest", bundleName: "com.example.featureabilitytest",
abilityName: "com.example.featureabilitytest.MainAbility", abilityName: "com.example.featureabilitytest.MainAbility",
...@@ -151,12 +153,12 @@ Starts an ability. This method uses a promise to return the execution result whe ...@@ -151,12 +153,12 @@ Starts an ability. This method uses a promise to return the execution result whe
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| --------- | ----------------------------------------------- | ---- | ------------------- | | --------- | ----------------------------------------------- | ---- | ------------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| | parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
**Return value** **Return value**
| Type| Description| | Type | Description |
| ----------------------------------------- | -------------- | | ----------------------------------------- | -------------- |
| Promise\<[AbilityResult](#abilityresult)> | Promised returned with the execution result.| | Promise\<[AbilityResult](#abilityresult)> | Promised returned with the execution result.|
...@@ -164,6 +166,7 @@ Starts an ability. This method uses a promise to return the execution result whe ...@@ -164,6 +166,7 @@ Starts an ability. This method uses a promise to return the execution result whe
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
import wantConstant from '@ohos.ability.wantConstant'
featureAbility.startAbilityForResult( featureAbility.startAbilityForResult(
{ {
want: want:
...@@ -171,7 +174,7 @@ featureAbility.startAbilityForResult( ...@@ -171,7 +174,7 @@ featureAbility.startAbilityForResult(
action: "action.system.home", action: "action.system.home",
entities: ["entity.system.home"], entities: ["entity.system.home"],
type: "MIMETYPE", type: "MIMETYPE",
flags: FLAG_AUTH_READ_URI_PERMISSION, flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "", deviceId: "",
bundleName: "com.example.featureabilitytest", bundleName: "com.example.featureabilitytest",
abilityName: "com.example.featureabilitytest.MainAbility", abilityName: "com.example.featureabilitytest.MainAbility",
...@@ -190,7 +193,7 @@ featureAbility.startAbilityForResult( ...@@ -190,7 +193,7 @@ featureAbility.startAbilityForResult(
}, },
requestCode: 2, requestCode: 2,
}, },
).then((void) => { ).then((data) => {
console.info("==========================>startAbilityForResult=======================>"); console.info("==========================>startAbilityForResult=======================>");
}); });
``` ```
...@@ -203,15 +206,16 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ...@@ -203,15 +206,16 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| --------- | ------------- | ---- | ------------------- | | --------- | ------------- | ---- | ------------------- |
| parameter | [AbilityResult](#abilityresult) | Yes| Ability to start.| | parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import wantConstant from '@ohos.ability.wantConstant'
featureAbility.terminateSelfWithResult( featureAbility.terminateSelfWithResult(
{ {
resultCode: 1, resultCode: 1,
...@@ -220,7 +224,7 @@ featureAbility.terminateSelfWithResult( ...@@ -220,7 +224,7 @@ featureAbility.terminateSelfWithResult(
action: "action.system.home", action: "action.system.home",
entities: ["entity.system.home"], entities: ["entity.system.home"],
type: "MIMETYPE", type: "MIMETYPE",
flags: FLAG_AUTH_READ_URI_PERMISSION, flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "", deviceId: "",
bundleName: "com.example.featureabilitytest", bundleName: "com.example.featureabilitytest",
abilityName: "com.example.featureabilitytest.MainAbility", abilityName: "com.example.featureabilitytest.MainAbility",
...@@ -248,12 +252,12 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ...@@ -248,12 +252,12 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ------------------- | | --------- | ------------------------------- | ---- | ------------------- |
| parameter | [AbilityResult](#abilityresult) | Yes| Ability to start.| | parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.|
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------------- | ----------------------- | | -------------- | ----------------------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
...@@ -261,6 +265,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ...@@ -261,6 +265,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
import wantConstant from '@ohos.ability.wantConstant'
featureAbility.terminateSelfWithResult( featureAbility.terminateSelfWithResult(
{ {
resultCode: 1, resultCode: 1,
...@@ -269,7 +274,7 @@ featureAbility.terminateSelfWithResult( ...@@ -269,7 +274,7 @@ featureAbility.terminateSelfWithResult(
action: "action.system.home", action: "action.system.home",
entities: ["entity.system.home"], entities: ["entity.system.home"],
type: "MIMETYPE", type: "MIMETYPE",
flags: FLAG_AUTH_READ_URI_PERMISSION, flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "", deviceId: "",
bundleName: "com.example.featureabilitytest", bundleName: "com.example.featureabilitytest",
abilityName: "com.example.featureabilitytest.MainAbility", abilityName: "com.example.featureabilitytest.MainAbility",
...@@ -286,7 +291,7 @@ featureAbility.terminateSelfWithResult( ...@@ -286,7 +291,7 @@ featureAbility.terminateSelfWithResult(
} }
}, },
} }
).then((void) => { ).then((data) => {
console.info("==========================>terminateSelfWithResult=======================>"); console.info("==========================>terminateSelfWithResult=======================>");
}); });
``` ```
...@@ -301,9 +306,9 @@ Checks whether the main window of this ability has the focus. This method uses a ...@@ -301,9 +306,9 @@ Checks whether the main window of this ability has the focus. This method uses a
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------------------------ | | -------- | ----------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<boolean> | Yes| Callback used to return the result. <br>Returns **true** if the main window of this ability has the focus; returns **false** otherwise.| | callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>Returns **true** if the main window of this ability has the focus; returns **false** otherwise.|
**Example** **Example**
...@@ -322,7 +327,7 @@ Checks whether the main window of this ability has the focus. This method uses a ...@@ -322,7 +327,7 @@ Checks whether the main window of this ability has the focus. This method uses a
**Return value** **Return value**
| Type| Description| | Type | Description |
| ----------------- | ---------------------------------------------------------- | | ----------------- | ---------------------------------------------------------- |
| Promise\<boolean> | Returns **true** if the main window of this ability has the focus; returns **false** otherwise.| | Promise\<boolean> | Returns **true** if the main window of this ability has the focus; returns **false** otherwise.|
...@@ -330,7 +335,7 @@ Checks whether the main window of this ability has the focus. This method uses a ...@@ -330,7 +335,7 @@ Checks whether the main window of this ability has the focus. This method uses a
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
featureAbility.hasWindowFocus().then((void) => { featureAbility.hasWindowFocus().then((data) => {
console.info("==========================>hasWindowFocus=======================>"); console.info("==========================>hasWindowFocus=======================>");
}); });
``` ```
...@@ -345,9 +350,9 @@ Obtains the **Want** object sent from this ability. This method uses a callback ...@@ -345,9 +350,9 @@ Obtains the **Want** object sent from this ability. This method uses a callback
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ------------------ | | -------- | ----------------------------- | ---- | ------------------ |
| callback | AsyncCallback\<[Want](#want)> | Yes| Callback used to return the result.| | callback | AsyncCallback\<[Want](#want)> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -365,7 +370,7 @@ getWant(): Promise\<Want> ...@@ -365,7 +370,7 @@ getWant(): Promise\<Want>
Obtains the **Want** object sent from this ability. This method uses a promise to return the result. Obtains the **Want** object sent from this ability. This method uses a promise to return the result.
**Return value** **Return value**
| Type| Description| | Type | Description |
| ----------------------- | ------------------------- | | ----------------------- | ------------------------- |
| Promise\<[Want](#want)> | Promise used to return the result.| | Promise\<[Want](#want)> | Promise used to return the result.|
...@@ -373,7 +378,7 @@ Obtains the **Want** object sent from this ability. This method uses a promise t ...@@ -373,7 +378,7 @@ Obtains the **Want** object sent from this ability. This method uses a promise t
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
featureAbility.getWant().then((void) => { featureAbility.getWant().then((data) => {
console.info("==========================>getWantCallBack=======================>"); console.info("==========================>getWantCallBack=======================>");
}); });
``` ```
...@@ -385,7 +390,7 @@ getContext(): Context ...@@ -385,7 +390,7 @@ getContext(): Context
Obtains the application context. Obtains the application context.
**Return value** **Return value**
| Type| Description| | Type | Description |
| ------- | -------------------- | | ------- | -------------------- |
| Context | Application context returned.| | Context | Application context returned.|
...@@ -407,9 +412,9 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ...@@ -407,9 +412,9 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------- | | -------- | -------------------- | ---- | ---------------- |
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -427,7 +432,7 @@ terminateSelf(): Promise\<void> ...@@ -427,7 +432,7 @@ terminateSelf(): Promise\<void>
Destroys this Page ability, with the result code and data sent to the caller. This method uses a promise to return the result. Destroys this Page ability, with the result code and data sent to the caller. This method uses a promise to return the result.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------------- | ------------------------- | | -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
...@@ -435,7 +440,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ...@@ -435,7 +440,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
featureAbility.terminateSelf().then((void) => { console.info("==========================>terminateSelfCallBack=======================>"); featureAbility.terminateSelf().then((data) => { console.info("==========================>terminateSelfCallBack=======================>");
}); });
``` ```
...@@ -447,35 +452,36 @@ Connects this ability to a specific Service ability. This method uses a callback ...@@ -447,35 +452,36 @@ Connects this ability to a specific Service ability. This method uses a callback
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ------- | -------------- | ---- | ---------------------------- | | ------- | -------------- | ---- | ---------------------------- |
| request | [Want](#want) | Yes| Service ability to connect.| | request | [Want](#want) | Yes | Service ability to connect.|
| options | ConnectOptions | Yes| Callback used to return the result.| | options | ConnectOptions | Yes | Callback used to return the result. |
Want Want
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable | Type | Mandatory| Description |
| ------------ | -------- | -------- | ---- | ---------------------------------- | | ------------ | -------- | -------- | ---- | ---------------------------------- |
| deviceId | Read-only| string | No| Device ID of the Service ability to connect. The default value is the local device ID.| | deviceId | Read-only | string | No | Device ID of the Service ability to connect. The default value is the local device ID.<br>|
| bundleName | Read-only| string | Yes| Bundle name of the Service ability to connect.| | bundleName | Read-only | string | Yes | Bundle name of the Service ability to connect.<br> |
| abilityName | Read-only| string | Yes| Class name of the Service ability to connect.| | abilityName | Read-only | string | Yes | Class name of the Service ability to connect.<br> |
ConnectOptions ConnectOptions
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| ------------ | -------- | -------- | ---- | ---------------------------------- | | ------------ | -------- | -------- | ---- | ---------------------------------- |
| onConnect | Read-only| function | Yes| Callback invoked when the connection is successful.| | onConnect | Read-only | function | Yes | Callback invoked when the connection is successful.<br> |
| onDisconnect | Read-only| function | Yes| Callback invoked when the connection fails.| | onDisconnect | Read-only | function | Yes | Callback invoked when the connection fails.<br> |
| onFailed | Read-only| function | Yes| Callback invoked when **connectAbility** fails to be called.| | onFailed | Read-only | function | Yes | Callback invoked when **connectAbility** fails to be called.<br>|
**Return value** **Return value**
| Type| Description| | Type | Description |
| ------ | ------------------------ | | ------ | ------------------------ |
| number | Returns the ID of the Service ability connected.| | number | Returns the ID of the Service ability connected.|
**Example** **Example**
```javascript ```javascript
import rpc from '@ohos.rpc'
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
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));
...@@ -488,7 +494,7 @@ function onFailedCallback(code){ ...@@ -488,7 +494,7 @@ function onFailedCallback(code){
} }
var connId = featureAbility.connectAbility( var connId = featureAbility.connectAbility(
{ {
deviceId: deviceId, deviceId: "",
bundleName: "com.ix.ServiceAbility", bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA", abilityName: "ServiceAbilityA",
}, },
...@@ -508,14 +514,15 @@ Disconnects this ability from a specific Service ability. This method uses a cal ...@@ -508,14 +514,15 @@ Disconnects this ability from a specific Service ability. This method uses a cal
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ---------- | ------------- | ---- | ------------------------------ | | ---------- | ------------- | ---- | ------------------------------ |
| connection | number | Yes| ID of the Service ability to disconnect.| | connection | number | Yes | ID of the Service ability to disconnect.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example** **Example**
```javascript ```javascript
import rpc from '@ohos.rpc'
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
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));
...@@ -552,18 +559,19 @@ Disconnects this ability from a specific Service ability. This method uses a pro ...@@ -552,18 +559,19 @@ Disconnects this ability from a specific Service ability. This method uses a pro
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------------------ | | ---------- | ------ | ---- | ------------------------------ |
| connection | number | Yes| ID of the Service ability to disconnect.| | connection | number | Yes | ID of the Service ability to disconnect.|
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------------- | ----------------------- | | -------------- | ----------------------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Example** **Example**
```javascript ```javascript
import rpc from '@ohos.rpc'
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
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));
...@@ -588,91 +596,51 @@ var connId = featureAbility.connectAbility( ...@@ -588,91 +596,51 @@ var connId = featureAbility.connectAbility(
var result = await featureAbility.disconnectAbility(connId); var result = await featureAbility.disconnectAbility(connId);
``` ```
## featureAbility.continueAbility
continueAbility(options: ContinueAbilityOptions, callback: AsyncCallback\<void>): void
Migrates an ability to another device. This method uses a callback to return the execution result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | ---------------------- | ---- | ------------------- |
| options | ContinueAbilityOptions | Yes| Ability to migrate.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
ContinueAbilityOptions
| Name| Readable/Writable| Type| Mandatory| Description|
| ---------- | -------- | ------- | ---- | ------------------------------------------------------------ |
| deviceId | Read-only| string | Yes| Information about the ability to migrate.|
| reversible | Read-only| boolean | Yes| Whether migration back is supported. Currently, this feature is not supported. This parameter is reserved and can be set to **false**.|
**Example**
```javascript
import featureAbility from '@ohos.ability.featureAbility'
async StartContinueAbility(deviceId) {
let continueAbilityOptions = {
reversible: false,
deviceId: deviceId,
}
function ContinueAbilityCallback(err, data) {
console.info("[Demo] ContinueAbilityCallback, result err = " + JSON.stringify(err));
console.info("[Demo] ContinueAbilityCallback, result data= " + JSON.stringify(data));
}
await featureAbility.continueAbility(continueAbilityOptions, ContinueAbilityCallback);
console.info('[Demo] featureAbility.StartContinueAbility end');
}
this.StartContinueAbility(remoteDeviceId); //remoteDeviceId is acquired from DeviceManager
```
## AbilityResult ## AbilityResult
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| ---------- | -------- | --------------------- | ---- | ------------------------------------------------------------ | | ---------- | -------- | --------------------- | ---- | ------------------------------------------------------------ |
| resultCode | Read-only| number | Yes| Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.| | resultCode | Read-only | number | Yes | Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.<br>|
| want | Read-only| [Want](#want) | No| Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**.| | want | Read-only | [Want](#want) | No | Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**.<br> |
## StartAbilityParameter ## StartAbilityParameter
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| ------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | | ------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| want | Read-only| [Want](#want) | Yes| Information about the ability to start.| | want | Read-only | [Want](#want) | Yes | Information about the ability to start.<br> |
| abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.| | abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.<br>|
## Want ## Want
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| deviceId | Read-only| string | No| ID of the device that runs the ability.| | deviceId | Read-only | string | No | ID of the device that runs the ability.<br> |
| bundleName | Read-only| string | No| Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| | bundleName | Read-only | string | No | Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.<br>|
| abilityName | Read-only| string | No| Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| | abilityName | Read-only | string | No | Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.<br>|
| uri | Read-only| string | No| URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| | uri | Read-only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.<br>|
| type | Read-only| string | No| MIME type, for example, text/plain or image/*.| | type | Read-only | string | No | MIME type, for example, text/plain or image/*.<br> |
| flags | Read-only| number | No| How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).| | flags | Read-only | number | No | How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).<br>|
| action | Read-only| string | No| Action option.| | action | Read-only | string | No | Action option.<br> |
| parameters | Read-only| {[key: string]: any} | No| List of parameters in a **Want** object.| | parameters | Read-only | {[key: string]: any} | No | List of parameters in a **Want** object.<br> |
| entities | Read-only| Array\<string> | No| List of entities.| | entities | Read-only | Array\<string> | No | List of entities.<br> |
## flags ## flags
| Name| Name| Description| | Name | Name | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ | | ------------------------------------ | ---------- | ------------------------------------------------------------ |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.| | FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.<br> |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.| | FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.<br> |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.| | FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.<br> |
| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.| | FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.<br> |
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.| | FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.<br> |
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.| | FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.<br> |
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.| | FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.<br> |
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.| | FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.<br> |
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.| | FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.<br> |
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.| | FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.<br> |
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.| | FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.<br> |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.| | FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.<br> |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.| | FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.<br> |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.| | FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.<br>|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.| | FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.<br> |
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.| | FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.<br>|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册