提交 45108d0d 编写于 作者: G Gloria

Update docs against 13858+14412+14118+14303+14859+14771+14118

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 459882dd
# @ohos.app.ability.dialogRequest (dialogRequest)
The **dialogRequest** module provides APIs related to modal dialog box processing, including obtaining the request information (used to bind a modal dialog box) and request callback (used to set the request result).
A modal dialog box is a system pop-up box that intercepts events (such as mouse, keyboard, and touchscreen events) triggered for the page displayed under it. The page can be operated only after the modal dialog box is destroyed.
> **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 provided by this module are used in ServiceExtensionAbilities. For a ServiceExtensionAbility that implements modal dialog boxes, you can use the APIs to obtain the request information and request callback and return the request result.
## Modules to Import
```js
import dialogRequest from '@ohos.app.ability.dialogRequest';
```
## dialogRequest.getRequestInfo
getRequestInfo(want: Want): RequestInfo
Obtains the request information from Want.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| want | [Want](js-apis-application-want.md) | Yes | Want passed in the request for a modal dialog box.|
**Return value**
| Type | Description |
| ------ | ------------------------ |
| [RequestInfo](#requestinfo) | **RequestInfo** object obtained, which is used to bind a modal dialog box.|
**Example**
```ts
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
import rpc from '@ohos.rpc';
import dialogRequest from '@ohos.app.ability.dialogRequest';
export default class ServiceExtAbility extends ServiceExtensionAbility {
onCreate(want) {
console.info(TAG, `onCreate, want: ${want.abilityName}`);
}
onRequest(want, startId) {
console.info(TAG, `onRequest, want: ${want.abilityName}`);
try {
var requestInfo = dialogRequest.getRequestInfo(want);
} catch(err) {
console.error('getRequestInfo err= ${JSON.stringify(err)}');
}
}
onConnect(want) {
console.info(TAG, `onConnect, want: ${want.abilityName}`);
}
onDisconnect(want) {
console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
}
onDestroy() {
console.info(TAG, `onDestroy`);
}
}
```
## dialogRequest.getRequestCallback
getRequestCallback(want: Want): RequestCallback
Obtains the request callback from Want.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| want | [Want](js-apis-application-want.md) | Yes | Want passed in the request for a modal dialog box.|
**Return value**
| Type | Description |
| ------ | ------------------------ |
| [RequestCallback](#requestcallback) | **RequestCallback** object obtained, which is used to set the return result.|
**Example**
```ts
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
import rpc from '@ohos.rpc';
import dialogRequest from '@ohos.app.ability.dialogRequest';
export default class ServiceExtAbility extends ServiceExtensionAbility {
onCreate(want) {
console.info(TAG, `onCreate, want: ${want.abilityName}`);
}
onRequest(want, startId) {
console.info(TAG, `onRequest, want: ${want.abilityName}`);
try {
var requestCallback = dialogRequest.getRequestCallback(want);
} catch(err) {
console.error('getRequestInfo err= ${JSON.stringify(err)}');
}
}
onConnect(want) {
console.info(TAG, `onConnect, want: ${want.abilityName}`);
}
onDisconnect(want) {
console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
}
onDestroy() {
console.info(TAG, `onDestroy`);
}
}
```
## RequestInfo
Defines the request information, which is used as an input parameter for binding the modal dialog box.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
```ts
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
import rpc from '@ohos.rpc';
import dialogRequest from '@ohos.app.ability.dialogRequest';
import window from '@ohos.window';
export default class ServiceExtAbility extends ServiceExtensionAbility {
onCreate(want) {
console.info(TAG, `onCreate, want: ${want.abilityName}`);
}
onRequest(want, startId) {
console.info(TAG, `onRequest, want: ${want.abilityName}`);
try {
var requestInfo = dialogRequest.getRequestInfo(want);
window.bindDialogTarget(requestInfo, () => {
console.info('Dialog Window Need Destroy.');
}, (err) => {
if (err.code) {
console.error('Failed to bind dialog target. Cause: ${JSON.stringify(err)}');
return;
}
console.info('Succeeded in binding dialog target.');
});
} catch(err) {
console.error('getRequestInfo err= ${JSON.stringify(err)}');
}
}
onConnect(want) {
console.info(TAG, `onConnect, want: ${want.abilityName}`);
}
onDisconnect(want) {
console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
}
onDestroy() {
console.info(TAG, `onDestroy`);
}
}
```
## ResultCode
Enumerates the result codes of the request for the modal dialog box.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name | Value | Description |
| ------------ | ------------------ | ---------------------- |
| RESULT_OK | 0 | The request succeeds. |
| RESULT_CANCEL | 1 | The request fails. |
## RequestResult
Defines the result of the request for the modal dialog box. Only the result code is included.
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| result | [ResultCode](#resultcode) | Yes| Yes| Result code of the request.|
## RequestCallback
Provides a callback for setting the modal dialog box request result.
### RequestCallback.setRequestResult
setRequestResult(result: RequestResult): void;
Sets the result of the request for the modal dialog box.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| result | [RequestResult](#requestresult) | Yes| Request result to set.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
import rpc from '@ohos.rpc';
import dialogRequest from '@ohos.app.ability.dialogRequest';
export default class ServiceExtAbility extends ServiceExtensionAbility {
onCreate(want) {
console.info(TAG, `onCreate, want: ${want.abilityName}`);
}
onRequest(want, startId) {
console.info(TAG, `onRequest, want: ${want.abilityName}`);
try {
var requestCallback = dialogRequest.getRequestCallback(want);
let myResult = {
result : dialogRequest.ResultCode.RESULT_CANCEL,
};
requestCallback.setRequestResult(myResult);
} catch(err) {
console.error('getRequestInfo err= ${JSON.stringify(err)}');
}
}
onConnect(want) {
console.info(TAG, `onConnect, want: ${want.abilityName}`);
}
onDisconnect(want) {
console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
}
onDestroy() {
console.info(TAG, `onDestroy`);
}
}
```
......@@ -18,7 +18,8 @@
| config | [Configuration](js-apis-app-ability-configuration.md) | Yes| No| UIAbility configuration, such as the language and color mode.|
> **NOTE**
> - In the sample code provided in this topic, **this.context** is used to obtain **UIAbilityContext**, where **this** indicates a UIAbility instance inherited from **UIAbility**. To use **UIAbilityContext** capabilities on pages, see [Obtaining the Context of UIAbility](../../application-models/uiability-usage.md#obtaining-the-context-of-uiability).
>
> In the sample code provided in this topic, **this.context** is used to obtain **UIAbilityContext**, where **this** indicates a UIAbility instance inherited from **UIAbility**. To use **UIAbilityContext** APIs on pages, see [Obtaining the Context of UIAbility](../../application-models/uiability-usage.md#obtaining-the-context-of-uiability).
## UIAbilityContext.startAbility
......@@ -44,50 +45,42 @@ Observe the following when using this API:
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. |
| 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. |
| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. |
| 16000055 | Free install timeout. |
| 16000056 | Can not free install other ability. |
| 16000057 | Not support cross device free install. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
bundleName: "com.example.myapp",
abilityName: "MyAbility"
};
try {
this.context.startAbility(want, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log('startAbility succeed');
});
} catch (paramError) {
// Process input parameter errors.
console.log('startAbility failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
try {
this.context.startAbility(want, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startAbility succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`startAbility failed failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startAbility
......@@ -115,54 +108,46 @@ Observe the following when using this API:
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. |
| 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. |
| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. |
| 16000055 | Free install timeout. |
| 16000056 | Can not free install other ability. |
| 16000057 | Not support cross device free install. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "MainAbility"
};
var options = {
windowMode: 0
};
try {
this.context.startAbility(want, options, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log('startAbility succeed');
});
} catch (paramError) {
// Process input parameter errors.
console.log('startAbility failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let options = {
windowMode: 0
};
try {
this.context.startAbility(want, options, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startAbility succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`startAbility failed failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startAbility
......@@ -195,60 +180,55 @@ Observe the following when using this API:
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. |
| 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. |
| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. |
| 16000055 | Free install timeout. |
| 16000056 | Can not free install other ability. |
| 16000057 | Not support cross device free install. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
bundleName: "com.example.myapp",
abilityName: "MyAbility"
};
var options = {
windowMode: 0,
};
try {
this.context.startAbility(want, options)
.then(() => {
// Carry out normal service processing.
console.log('startAbility succeed');
})
.catch((error) => {
// Process service logic errors.
console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// Process input parameter errors.
console.log('startAbility failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let options = {
windowMode: 0,
};
try {
this.context.startAbility(want, options)
.then(() => {
// Carry out normal service processing.
console.info('startAbility succeed');
})
.catch((err) => {
// Process service logic errors.
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startAbilityForResult
startAbilityForResult(want: Want, callback: AsyncCallback&lt;AbilityResult&gt;): void;
Starts an ability. After the ability is started, you can call [terminateSelfWithResult](#uiabilitycontextterminateselfwithresult) 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](#uiabilitycontextterminateselfwithresult) to terminate the ability. The result is returned to the caller.
- If an exception occurs, for example, the ability is killed, an error message, in which **resultCode** is **-1**, is returned to the caller.
- If different applications call this API to start an ability that uses the singleton mode and then call [terminateSelfWithResult](#uiabilitycontextterminateselfwithresult) to terminate the ability, the normal result is returned to the last caller, and an error 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.
......@@ -268,58 +248,53 @@ Observe the following when using this API:
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. |
| 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. |
| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. |
| 16000055 | Free install timeout. |
| 16000056 | Can not free install other ability. |
| 16000057 | Not support cross device free install. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "MainAbility"
};
try {
this.context.startAbilityForResult(want, (error, result) => {
if (error.code) {
// Process service logic errors.
console.log('startAbilityForResult failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log("startAbilityForResult succeed, result.resultCode = " + result.resultCode)
});
} catch (paramError) {
// Process input parameter errors.
console.log('startAbilityForResult failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
try {
this.context.startAbilityForResult(want, (err, result) => {
if (err.code) {
// Process service logic errors.
console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startAbilityForResult succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startAbilityForResult
startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback&lt;AbilityResult&gt;): void;
Starts an ability with the start options specified. After the ability is started, you can call [terminateSelfWithResult](#uiabilitycontextterminateselfwithresult) 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 with the start options specified. 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](#uiabilitycontextterminateselfwithresult) to terminate the ability. The result is returned to the caller.
- If an exception occurs, for example, the ability is killed, an error message, in which **resultCode** is **-1**, is returned to the caller.
- If different applications call this API to start an ability that uses the singleton mode and then call [terminateSelfWithResult](#uiabilitycontextterminateselfwithresult) to terminate the ability, the normal result is returned to the last caller, and an error 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.
......@@ -340,54 +315,46 @@ Observe the following when using this API:
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. |
| 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. |
| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. |
| 16000055 | Free install timeout. |
| 16000056 | Can not free install other ability. |
| 16000057 | Not support cross device free install. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "MainAbility"
};
var options = {
windowMode: 0,
};
try {
this.context.startAbilityForResult(want, options, (error, result) => {
if (error.code) {
// Process service logic errors.
console.log('startAbilityForResult failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log("startAbilityForResult succeed, result.resultCode = " + result.resultCode)
});
} catch (paramError) {
// Process input parameter errors.
console.log('startAbilityForResult failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let options = {
windowMode: 0,
};
try {
this.context.startAbilityForResult(want, options, (err, result) => {
if (err.code) {
// Process service logic errors.
console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startAbilityForResult succeed');
});
} catch (paramError) {
// Process input parameter errors.
console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`);
}
```
......@@ -395,7 +362,10 @@ Observe the following when using this API:
startAbilityForResult(want: Want, options?: StartOptions): Promise&lt;AbilityResult&gt;;
Starts an ability. After the ability is started, you can call [terminateSelfWithResult](#uiabilitycontextterminateselfwithresult) 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](#uiabilitycontextterminateselfwithresult) to terminate the ability. The result is returned to the caller.
- If an exception occurs, for example, the ability is killed, an error message, in which **resultCode** is **-1**, is returned to the caller.
- If different applications call this API to start an ability that uses the singleton mode and then call [terminateSelfWithResult](#uiabilitycontextterminateselfwithresult) to terminate the ability, the normal result is returned to the last caller, and an error 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.
......@@ -422,53 +392,45 @@ Observe the following when using this API:
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. |
| 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. |
| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. |
| 16000055 | Free install timeout. |
| 16000056 | Can not free install other ability. |
| 16000057 | Not support cross device free install. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
bundleName: "com.example.myapplication",
abilityName: "MainAbility"
};
var options = {
windowMode: 0,
};
try {
this.context.startAbilityForResult(want, options)
.then((result) => {
// Carry out normal service processing.
console.log("startAbilityForResult succeed, result.resultCode = " + result.resultCode);
})
.catch((error) => {
// Process service logic errors.
console.log('startAbilityForResult failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// Process input parameter errors.
console.log('startAbilityForResult failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let options = {
windowMode: 0,
};
try {
this.context.startAbilityForResult(want, options)
.then((result) => {
// Carry out normal service processing.
console.info('startAbilityForResult succeed');
})
.catch((err) => {
// Process service logic errors.
console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startAbilityForResultWithAccount
......@@ -500,54 +462,44 @@ Observe the following when using this API:
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000006 | Can not cross user operations. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. |
| 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. |
| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. |
| 16000055 | Free install timeout. |
| 16000056 | Can not free install other ability. |
| 16000057 | Not support cross device free install. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "MainAbility"
};
var accountId = 100;
try {
this.context.startAbilityForResultWithAccount(want, accountId, (error, result) => {
if (error.code) {
// Process service logic errors.
console.log('startAbilityForResultWithAccount failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log("startAbilityForResultWithAccount succeed, result.resultCode = " +
result.resultCode + ' result.want = ' + JSON.stringify(result.want))
});
} catch (paramError) {
// Process input parameter errors.
console.log('startAbilityForResultWithAccount failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let accountId = 100;
try {
this.context.startAbilityForResultWithAccount(want, accountId, (err, result) => {
if (err.code) {
// Process service logic errors.
console.error(`startAbilityForResultWithAccount failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startAbilityForResultWithAccount succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`startAbilityForResultWithAccount failed, code is ${err.code}, message is ${err.message}`);
}
```
......@@ -581,56 +533,47 @@ Observe the following when using this API:
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000006 | Can not cross user operations. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. |
| 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. |
| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. |
| 16000055 | Free install timeout. |
| 16000056 | Can not free install other ability. |
| 16000057 | Not support cross device free install. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "MainAbility"
};
var accountId = 100;
var options = {
windowMode: 0
};
try {
this.context.startAbilityForResultWithAccount(want, accountId, options, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startAbilityForResultWithAccount failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log("startAbilityForResultWithAccount succeed")
});
} catch (paramError) {
// Process input parameter errors.
console.log('startAbilityForResultWithAccount failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let accountId = 100;
let options = {
windowMode: 0
};
try {
this.context.startAbilityForResultWithAccount(want, accountId, options, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`startAbilityForResultWithAccount failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startAbilityForResultWithAccount succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`startAbilityForResultWithAccount failed, code is ${err.code}, message is ${err.message}`);
}
```
......@@ -669,57 +612,47 @@ Observe the following when using this API:
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000006 | Can not cross user operations. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. |
| 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. |
| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. |
| 16000055 | Free install timeout. |
| 16000056 | Can not free install other ability. |
| 16000057 | Not support cross device free install. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "MainAbility"
};
var accountId = 100;
var options = {
windowMode: 0
};
try {
this.context.startAbilityForResultWithAccount(want, accountId, options)
.then((result) => {
// Carry out normal service processing.
console.log("startAbilityForResultWithAccount succeed, result.resultCode = " +
result.resultCode)
})
.catch((error) => {
// Process service logic errors.
console.log('startAbilityForResultWithAccount failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// Process input parameter errors.
console.log('startAbilityForResultWithAccount failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let accountId = 100;
let options = {
windowMode: 0
};
try {
this.context.startAbilityForResultWithAccount(want, accountId, options)
.then((result) => {
// Carry out normal service processing.
console.info('startAbilityForResultWithAccount succeed');
})
.catch((err) => {
// Process service logic errors.
console.error(`startAbilityForResultWithAccount failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
console.error(`startAbilityForResultWithAccount failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startServiceExtensionAbility
......@@ -742,44 +675,38 @@ Starts a ServiceExtensionAbility. This API uses an asynchronous callback to retu
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000002 | Ability type error. The specified ability type is wrong. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000011 | Context does not exist. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "ServiceExtensionAbility"
};
try {
this.context.startServiceExtensionAbility(want, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility'
};
try {
this.context.startServiceExtensionAbility(want)
.then(() => {
// Carry out normal service processing.
console.log('startServiceExtensionAbility succeed');
console.info('startServiceExtensionAbility succeed');
})
.catch((err) => {
// Process service logic errors.
console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
});
} catch (paramError) {
// Process input parameter errors.
console.log('startServiceExtensionAbility failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
} catch (err) {
// Process input parameter errors.
console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startServiceExtensionAbility
......@@ -802,44 +729,38 @@ Starts a ServiceExtensionAbility. This API uses a promise to return the result.
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000002 | Ability type error. The specified ability type is wrong. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000011 | Context does not exist. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "ServiceExtensionAbility"
};
try {
this.context.startServiceExtensionAbility(want)
.then(() => {
// Carry out normal service processing.
console.log('startServiceExtensionAbility succeed');
})
.catch((error) => {
// Process service logic errors.
console.log('startServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// Process input parameter errors.
console.log('startServiceExtensionAbility failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility'
};
try {
this.context.startServiceExtensionAbility(want)
.then(() => {
// Carry out normal service processing.
console.info('startServiceExtensionAbility succeed');
})
.catch((err) => {
// Process service logic errors.
console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
});
} catch (paramError) {
// Process input parameter errors.
console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startServiceExtensionAbilityWithAccount
......@@ -866,42 +787,39 @@ Starts a ServiceExtensionAbility with the account ID specified. This API uses an
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000002 | Ability type error. The specified ability type is wrong. |
| 16000004 | Visibility verification failed. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000011 | Context does not exist. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "ServiceExtensionAbility"
};
var accountId = 100;
try {
this.context.startServiceExtensionAbilityWithAccount(want, accountId, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startServiceExtensionAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log('startServiceExtensionAbilityWithAccount succeed');
});
} catch (paramError) {
// Process input parameter errors.
console.log('startServiceExtensionAbilityWithAccount failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility'
};
let accountId = 100;
try {
this.context.startServiceExtensionAbilityWithAccount(want, accountId, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`startServiceExtensionAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startServiceExtensionAbilityWithAccount succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`startServiceExtensionAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startServiceExtensionAbilityWithAccount
......@@ -927,46 +845,39 @@ Starts a ServiceExtensionAbility with the account ID specified. This API uses a
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000002 | Ability type error. The specified ability type is wrong. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000006 | Can not cross user operations. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000011 | Context does not exist. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "ServiceExtensionAbility"
};
var accountId = 100;
try {
this.context.startServiceExtensionAbilityWithAccount(want, accountId)
.then((data) => {
// Carry out normal service processing.
console.log('startServiceExtensionAbilityWithAccount succeed');
})
.catch((error) => {
// Process service logic errors.
console.log('startServiceExtensionAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// Process input parameter errors.
console.log('startServiceExtensionAbilityWithAccount failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility'
};
let accountId = 100;
try {
this.context.startServiceExtensionAbilityWithAccount(want, accountId)
.then(() => {
// Carry out normal service processing.
console.info('startServiceExtensionAbilityWithAccount succeed');
})
.catch((err) => {
// Process service logic errors.
console.error(`startServiceExtensionAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
console.error(`startServiceExtensionAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.stopServiceExtensionAbility
......@@ -989,41 +900,37 @@ Stops a ServiceExtensionAbility in the same application. This API uses an asynch
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000002 | Ability type error. The specified ability type is wrong. |
| 16000004 | Visibility verification failed. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000011 | Context does not exist. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "ServiceExtensionAbility"
};
try {
this.context.stopServiceExtensionAbility(want, (error) => {
if (error.code) {
// Process service logic errors.
console.log('stopServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log('stopServiceExtensionAbility succeed');
});
} catch (paramError) {
// Process input parameter errors.
console.log('stopServiceExtensionAbility failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility'
};
try {
this.context.stopServiceExtensionAbility(want, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`stopServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('stopServiceExtensionAbility succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`stopServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.stopServiceExtensionAbility
......@@ -1046,41 +953,37 @@ Stops a ServiceExtensionAbility in the same application. This API uses a promise
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000002 | Ability type error. The specified ability type is wrong. |
| 16000004 | Visibility verification failed. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000011 | Context does not exist. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "ServiceExtensionAbility"
};
try {
this.context.stopServiceExtensionAbility(want)
.then((data) => {
// Carry out normal service processing.
console.log('stopServiceExtensionAbility succeed');
})
.catch((error) => {
// Process service logic errors.
console.log('stopServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// Process input parameter errors.
console.log('stopServiceExtensionAbility failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility'
};
try {
this.context.stopServiceExtensionAbility(want)
.then(() => {
// Carry out normal service processing.
console.info('stopServiceExtensionAbility succeed');
})
.catch((err) => {
// Process service logic errors.
console.error(`stopServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
console.error(`stopServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.stopServiceExtensionAbilityWithAccount
......@@ -1107,43 +1010,38 @@ Stops a ServiceExtensionAbility with the account ID specified in the same applic
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000002 | Ability type error. The specified ability type is wrong. |
| 16000004 | Visibility verification failed. |
| 16000006 | Can not cross user operations. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000011 | Context does not exist. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "ServiceExtensionAbility"
};
var accountId = 100;
try {
this.context.stopServiceExtensionAbilityWithAccount(want, accountId, (error) => {
if (error.code) {
// Process service logic errors.
console.log('stopServiceExtensionAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log('stopServiceExtensionAbilityWithAccount succeed');
});
} catch (paramError) {
// Process input parameter errors.
console.log('stopServiceExtensionAbilityWithAccount failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility'
};
let accountId = 100;
try {
this.context.stopServiceExtensionAbilityWithAccount(want, accountId, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`stopServiceExtensionAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('stopServiceExtensionAbilityWithAccount succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`stopServiceExtensionAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.stopServiceExtensionAbilityWithAccount
......@@ -1169,43 +1067,38 @@ Stops a ServiceExtensionAbility with the account ID specified in the same applic
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000002 | Ability type error. The specified ability type is wrong. |
| 16000004 | Visibility verification failed. |
| 16000006 | Can not cross user operations. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000011 | Context does not exist. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "ServiceExtensionAbility"
};
var accountId = 100;
try {
this.context.stopServiceExtensionAbilityWithAccount(want, accountId)
.then((data) => {
// Carry out normal service processing.
console.log('stopServiceExtensionAbilityWithAccount succeed');
})
.catch((error) => {
// Process service logic errors.
console.log('stopServiceExtensionAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// Process input parameter errors.
console.log('stopServiceExtensionAbilityWithAccount failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility'
};
let accountId = 100;
try {
this.context.stopServiceExtensionAbilityWithAccount(want, accountId)
.then(() => {
// Carry out normal service processing.
console.info('stopServiceExtensionAbilityWithAccount succeed');
})
.catch((err) => {
// Process service logic errors.
console.error(`stopServiceExtensionAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
console.error(`stopServiceExtensionAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.terminateSelf
......@@ -1226,31 +1119,29 @@ Terminates this ability. This API uses an asynchronous callback to return the re
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000011 | Context does not exist. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
```ts
try {
this.context.terminateSelf((error) => {
if (error.code) {
this.context.terminateSelf((err) => {
if (err.code) {
// Process service logic errors.
console.log('terminateSelf failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
console.error(`terminateSelf failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.log('terminateSelf succeed');
console.info('terminateSelf succeed');
});
} catch (error) {
} catch (err) {
// Capture the synchronization parameter error.
console.log('terminateSelf failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
console.error(`terminateSelf failed, code is ${err.code}, message is ${err.message}`);
}
```
......@@ -1273,12 +1164,12 @@ Terminates this ability. This API uses a promise to return the result.
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000011 | Context does not exist. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
......@@ -1287,17 +1178,15 @@ Terminates this ability. This API uses a promise to return the result.
this.context.terminateSelf()
.then(() => {
// Carry out normal service processing.
console.log('terminateSelf succeed');
console.info('terminateSelf succeed');
})
.catch((error) => {
.catch((err) => {
// Process service logic errors.
console.log('terminateSelf failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
console.error(`terminateSelf failed, code is ${err.code}, message is ${err.message}`);
});
} catch (error) {
// Capture the synchronization parameter error.
console.log('terminateSelf failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
console.error(`terminateSelf failed, code is ${err.code}, message is ${err.message}`);
}
```
......@@ -1306,7 +1195,7 @@ Terminates this ability. This API uses a promise to return the result.
terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback&lt;void&gt;): void;
Terminates this ability. If the ability is started by calling [startAbilityForResult](#uiabilitycontextstartabilityforresult), the result is returned to the caller in the form of a callback when **terminateSelfWithResult** is called. Otherwise, no result is returned to the caller when **terminateSelfWithResult** is called.
Terminates this ability. If the ability is started by calling [startAbilityForResult](#uiabilitycontextstartabilityforresult), the result is returned to the caller in the form of an asynchronous callback when **terminateSelfWithResult** is called. Otherwise, no result is returned to the caller when **terminateSelfWithResult** is called.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -1321,43 +1210,41 @@ Terminates this ability. If the ability is started by calling [startAbilityForRe
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000011 | Context does not exist. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
```ts
var want = {
bundleName: "com.example.myapplication",
abilityName: "MainAbility"
}
var resultCode = 100;
// AbilityResult information returned to the caller.
var abilityResult = {
want,
resultCode
}
try {
this.context.terminateSelfWithResult(abilityResult, (error) => {
if (error.code) {
// Process service logic errors.
console.log('terminateSelfWithResult failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log('terminateSelfWithResult succeed');
});
} catch (paramError) {
// Process input parameter errors.
console.log('terminateSelfWithResult failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let resultCode = 100;
// AbilityResult information returned to the caller.
let abilityResult = {
want,
resultCode
};
try {
this.context.terminateSelfWithResult(abilityResult, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`terminateSelfWithResult failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('terminateSelfWithResult succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`terminateSelfWithResult failed, code is ${err.code}, message is ${err.message}`);
}
```
......@@ -1385,44 +1272,41 @@ Terminates this ability. If the ability is started by calling [startAbilityForRe
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000011 | Context does not exist. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
```ts
var want = {
bundleName: "com.example.myapplication",
abilityName: "MainAbility"
}
var resultCode = 100;
// AbilityResult information returned to the caller.
var abilityResult = {
want,
resultCode
}
try {
this.context.terminateSelfWithResult(abilityResult)
.then((data) => {
// Carry out normal service processing.
console.log('terminateSelfWithResult succeed');
})
.catch((error) => {
// Process service logic errors.
console.log('terminateSelfWithResult failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// Process input parameter errors.
console.log('terminateSelfWithResult failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let resultCode = 100;
// AbilityResult information returned to the caller.
let abilityResult = {
want,
resultCode
};
try {
this.context.terminateSelfWithResult(abilityResult)
.then(() => {
// Carry out normal service processing.
console.info('terminateSelfWithResult succeed');
})
.catch((err) => {
// Process service logic errors.
console.error(`terminateSelfWithResult failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
console.error(`terminateSelfWithResult failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.connectServiceExtensionAbility
......@@ -1433,8 +1317,6 @@ Connects this ability to an ability that uses the **AbilityInfo.AbilityType.SERV
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -1452,42 +1334,38 @@ Connects this ability to an ability that uses the **AbilityInfo.AbilityType.SERV
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000002 | Ability type error. The specified ability type is wrong. |
| 16000004 | Visibility verification failed. |
| 16000011 | Context does not exist. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000005 | The specified process does not have the permission. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "ServiceExtensionAbility"
};
var options = {
onConnect(elementName, remote) {
console.log('----------- onConnect -----------')
},
onDisconnect(elementName) {
console.log('----------- onDisconnect -----------')
},
onFailed(code) {
console.log('----------- onFailed -----------')
}
}
var connection = null;
try {
connection = this.context.connectServiceExtensionAbility(want, options);
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility'
};
let options = {
onConnect(elementName, remote) {
console.info('onConnect...')
},
onDisconnect(elementName) {
console.info('onDisconnect...')
},
onFailed(code) {
console.info('onFailed...')
}
};
let connection = null;
try {
connection = this.context.connectServiceExtensionAbility(want, options);
} catch (err) {
// Process input parameter errors.
console.error(`connectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}
```
......@@ -1521,44 +1399,39 @@ Connects this ability to an ability that uses the **AbilityInfo.AbilityType.SERV
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000002 | Ability type error. The specified ability type is wrong. |
| 16000004 | Visibility verification failed. |
| 16000006 | Can not cross user operations. |
| 16000011 | Context does not exist. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000005 | The specified process does not have the permission. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "ServiceExtensionAbility"
};
var accountId = 100;
var options = {
onConnect(elementName, remote) {
console.log('----------- onConnect -----------')
},
onDisconnect(elementName) {
console.log('----------- onDisconnect -----------')
},
onFailed(code) {
console.log('----------- onFailed -----------')
}
}
var connection = null;
try {
connection = this.context.connectServiceExtensionAbilityWithAccount(want, accountId, options);
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility'
};
let accountId = 100;
let options = {
onConnect(elementName, remote) {
console.info('onConnect...')
},
onDisconnect(elementName) {
console.info('onDisconnect...')
},
onFailed(code) {
console.info('onFailed...')
}
};
let connection = null;
try {
connection = this.context.connectServiceExtensionAbilityWithAccount(want, accountId, options);
} catch (err) {
// Process input parameter errors.
console.error(`connectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.disconnectServiceExtensionAbility
......@@ -1569,8 +1442,6 @@ Disconnects from a ServiceExtensionAbility. This API uses a promise to return th
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -1587,35 +1458,31 @@ Disconnects from a ServiceExtensionAbility. This API uses a promise to return th
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000003 | Input error. The specified id does not exist. |
| 16000011 | Context does not exist. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000005 | The specified process does not have the permission. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
```ts
// connection is the return value of connectServiceExtensionAbility.
var connection = 1;
// connection is the return value of connectServiceExtensionAbility.
let connection = 1;
try {
this.context.disconnectServiceExtensionAbility(connection)
.then((data) => {
// Carry out normal service processing.
console.log('disconnectServiceExtensionAbility succeed');
})
.catch((error) => {
// Process service logic errors.
console.log('disconnectServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
try {
this.context.disconnectServiceExtensionAbility(connection, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('disconnectServiceExtensionAbility succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.disconnectServiceExtensionAbility
......@@ -1626,8 +1493,6 @@ Disconnects from a ServiceExtensionAbility. This API uses an asynchronous callba
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -1639,35 +1504,31 @@ Disconnects from a ServiceExtensionAbility. This API uses an asynchronous callba
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000003 | Input error. The specified id does not exist. |
| 16000011 | Context does not exist. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000005 | The specified process does not have the permission. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
```ts
// connection is the return value of connectServiceExtensionAbility.
var connection = 1;
// connection is the return value of connectServiceExtensionAbility.
let connection = 1;
try {
this.context.disconnectServiceExtensionAbility(connection, (error) => {
if (error.code) {
// Process service logic errors.
console.log('disconnectServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log('disconnectServiceExtensionAbility succeed');
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
try {
this.context.disconnectServiceExtensionAbility(connection, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('disconnectServiceExtensionAbility succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startAbilityByCall
......@@ -1695,71 +1556,85 @@ Observe the following when using this API:
| -------- | -------- |
| Promise&lt;Caller&gt; | Promise used to return the caller object to communicate with.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
Start an ability in the background.
```ts
var caller = undefined;
// Start an ability in the background by not passing parameters.
var wantBackground = {
bundleName: "com.example.myservice",
moduleName: "entry",
abilityName: "MainAbility",
deviceId: ""
};
try {
this.context.startAbilityByCall(wantBackground)
.then((obj) => {
// Carry out normal service processing.
caller = obj;
console.log('startAbilityByCall succeed');
}).catch((error) => {
// Process service logic errors.
console.log('startAbilityByCall failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let caller;
// Start an ability in the background by not passing parameters.
let wantBackground = {
bundleName: 'com.example.myapplication',
moduleName: 'entry',
abilityName: 'EntryAbility',
deviceId: ''
};
try {
this.context.startAbilityByCall(wantBackground)
.then((obj) => {
// Carry out normal service processing.
caller = obj;
console.info('startAbilityByCall succeed');
}).catch((err) => {
// Process service logic errors.
console.error(`startAbilityByCall failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
console.error(`startAbilityByCall failed, code is ${err.code}, message is ${err.message}`);
}
```
Start an ability in the foreground.
Start an ability in the foreground.
```ts
var caller = undefined;
// Start an ability in the foreground with ohos.aafwk.param.callAbilityToForeground in parameters set to true.
var wantForeground = {
bundleName: "com.example.myservice",
moduleName: "entry",
abilityName: "MainAbility",
deviceId: "",
parameters: {
"ohos.aafwk.param.callAbilityToForeground": true
}
};
try {
this.context.startAbilityByCall(wantForeground)
.then((obj) => {
// Carry out normal service processing.
caller = obj;
console.log('startAbilityByCall succeed');
}).catch((error) => {
// Process service logic errors.
console.log('startAbilityByCall failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
let caller;
// Start an ability in the foreground with ohos.aafwk.param.callAbilityToForeground in parameters set to true.
let wantForeground = {
bundleName: 'com.example.myapplication',
moduleName: 'entry',
abilityName: 'EntryAbility',
deviceId: '',
parameters: {
'ohos.aafwk.param.callAbilityToForeground': true
}
};
try {
this.context.startAbilityByCall(wantForeground)
.then((obj) => {
// Carry out normal service processing.
caller = obj;
console.info('startAbilityByCall succeed');
}).catch((error) => {
// Process service logic errors.
console.error(`startAbilityByCall failed, code is ${err.code}, message is ${err.message}`);
});
} catch (paramError) {
// Process input parameter errors.
console.error(`startAbilityByCall failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startAbilityWithAccount
......@@ -1791,53 +1666,44 @@ Observe the following when using this API:
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000006 | Can not cross user operations. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. |
| 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. |
| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. |
| 16000055 | Free install timeout. |
| 16000056 | Can not free install other ability. |
| 16000057 | Not support cross device free install. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "MainAbility"
};
var accountId = 100;
try {
this.context.startAbilityWithAccount(want, accountId, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log('startAbilityWithAccount succeed');
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let accountId = 100;
try {
this.context.startAbilityWithAccount(want, accountId, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`startAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startAbilityWithAccount succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`startAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
}
```
......@@ -1871,56 +1737,47 @@ Observe the following when using this API:
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000006 | Can not cross user operations. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. |
| 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. |
| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. |
| 16000055 | Free install timeout. |
| 16000056 | Can not free install other ability. |
| 16000057 | Not support cross device free install. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "MainAbility"
};
var accountId = 100;
var options = {
windowMode: 0
};
try {
this.context.startAbilityWithAccount(want, accountId, options, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// Carry out normal service processing.
console.log('startAbilityWithAccount succeed');
});
} catch (paramError) {
// Process input parameter errors.
console.log('startAbilityWithAccount failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let accountId = 100;
let options = {
windowMode: 0
};
try {
this.context.startAbilityWithAccount(want, accountId, options, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`startAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startAbilityWithAccount succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`startAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
}
```
......@@ -1953,63 +1810,54 @@ Observe the following when using this API:
| ID| Error Message|
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000006 | Can not cross user operations. |
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. |
| 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. |
| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. |
| 16000055 | Free install timeout. |
| 16000056 | Can not free install other ability. |
| 16000057 | Not support cross device free install. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
var want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "MainAbility"
};
var accountId = 100;
var options = {
windowMode: 0
};
try {
this.context.startAbilityWithAccount(want, accountId, options)
.then((data) => {
// Carry out normal service processing.
console.log('startAbilityWithAccount succeed');
})
.catch((error) => {
// Process service logic errors.
console.log('startAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// Process input parameter errors.
console.log('startAbilityWithAccount failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let accountId = 100;
let options = {
windowMode: 0
};
try {
this.context.startAbilityWithAccount(want, accountId, options)
.then(() => {
// Carry out normal service processing.
console.info('startAbilityWithAccount succeed');
})
.catch((err) => {
// Process service logic errors.
console.error(`startAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
console.error(`startAbilityWithAccount failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.setMissionLabel
setMissionLabel(label: string, callback:AsyncCallback&lt;void&gt;): void;
Sets a label for this ability in the mission. This API uses an asynchronous callback to return the result.
Sets a label for this UIAbility in the mission. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -2023,8 +1871,8 @@ Sets a label for this ability in the mission. This API uses an asynchronous call
**Example**
```ts
this.context.setMissionLabel("test", (result) => {
console.log('setMissionLabel:' + JSON.stringify(result));
this.context.setMissionLabel('test', (result) => {
console.info(`setMissionLabel: ${JSON.stringify(result)}`);
});
```
......@@ -2032,7 +1880,7 @@ Sets a label for this ability in the mission. This API uses an asynchronous call
setMissionLabel(label: string): Promise&lt;void&gt;;
Sets a label for this ability in the mission. This API uses a promise to return the result.
Sets a label for this UIAbility in the mission. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -2048,13 +1896,20 @@ Sets a label for this ability in the mission. This API uses a promise to return
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
```ts
this.context.setMissionLabel("test").then(() => {
console.log('success');
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
this.context.setMissionLabel('test').then(() => {
console.info('success');
}).catch((err) => {
console.error(`setMissionLabel failed, code is ${err.code}, message is ${err.message}`);
});
```
## UIAbilityContext.setMissionIcon
......@@ -2074,13 +1929,21 @@ Sets an icon for this ability in the mission. This API uses an asynchronous call
| icon | image.PixelMap | Yes| Icon of the ability to set.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
```ts
import image from '@ohos.multimedia.image';
var imagePixelMap;
var color = new ArrayBuffer(0);
var initializationOptions = {
let imagePixelMap;
let color = new ArrayBuffer(0);
let initializationOptions = {
size: {
height: 100,
width: 100
......@@ -2091,10 +1954,10 @@ Sets an icon for this ability in the mission. This API uses an asynchronous call
imagePixelMap = data;
})
.catch((err) => {
console.log('--------- createPixelMap fail, err: ---------', err)
console.error(`createPixelMap failed, code is ${err.code}, message is ${err.message}`);
});
this.context.setMissionIcon(imagePixelMap, (err) => {
console.log('---------- setMissionIcon fail, err: -----------', err);
console.error(`setMissionLabel failed, code is ${err.code}, message is ${err.message}`);
})
```
......@@ -2121,12 +1984,19 @@ Sets an icon for this ability in the mission. This API uses a promise to return
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
```ts
var imagePixelMap;
var color = new ArrayBuffer(0);
var initializationOptions = {
let imagePixelMap;
let color = new ArrayBuffer(0);
let initializationOptions = {
size: {
height: 100,
width: 100
......@@ -2137,21 +2007,21 @@ Sets an icon for this ability in the mission. This API uses a promise to return
imagePixelMap = data;
})
.catch((err) => {
console.log('--------- createPixelMap fail, err: ---------', err)
console.error(`createPixelMap failed, code is ${err.code}, message is ${err.message}`);
});
this.context.setMissionIcon(imagePixelMap)
.then(() => {
console.log('-------------- setMissionIcon success -------------');
console.info('setMissionIcon succeed');
})
.catch((err) => {
console.log('-------------- setMissionIcon fail, err: -------------', err);
console.error(`setMissionLabel failed, code is ${err.code}, message is ${err.message}`);
});
```
## UIAbilityContext.restoreWindowStage
restoreWindowStage(localStorage: LocalStorage) : void;
Restores the window stage data for this ability.
Restores the WindowStage data in the UIAbility.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -2161,10 +2031,17 @@ Restores the window stage data for this ability.
| -------- | -------- | -------- | -------- |
| localStorage | image.LocalStorage | Yes| Storage used to store the restored window stage.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
```ts
var storage = new LocalStorage();
let storage = new LocalStorage();
this.context.restoreWindowStage(storage);
```
......@@ -2172,7 +2049,7 @@ Restores the window stage data for this ability.
isTerminating(): boolean;
Checks whether this ability is in the terminating state.
Checks whether this UIAbility is in the terminating state.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -2180,11 +2057,117 @@ Checks whether this ability is in the terminating state.
| Type| Description|
| -------- | -------- |
| boolean| The value **true** means that the ability is in the terminating state, and **false** means the opposite.|
| boolean| The value **true** means that the UIAbility is in the terminating state, and **false** means the opposite.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
**Example**
```ts
var isTerminating = this.context.isTerminating();
console.log('ability state :' + isTerminating);
let isTerminating = this.context.isTerminating();
console.info(`ability state is ${isTerminating}`);
```
## UIAbilityContext.requestDialogService
requestDialogService(want: Want, result: AsyncCallback&lt;dialogRequest.RequestResult&gt;): void;
Starts a ServiceExtensionAbility that supports modal dialog boxes. After the ServiceExtensionAbility is started, the application displays a modal dialog box. You can call [setRequestResult](js-apis-app-ability-dialogRequest.md#requestcallbacksetrequestresult) to obtain the result.
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 **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 stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-want.md) | Yes| Want information about the target ServiceExtensionAbility.|
| result | AsyncCallback&lt;[dialogRequest.RequestResult](js-apis-app-ability-dialogRequest.md)&gt; | Yes| Callback used to return the result.|
**Example**
```ts
import dialogRequest from '@ohos.app.ability.dialogRequest';
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'AuthAccountServiceExtension'
};
try {
this.context.requestDialogService(want, (err, result) => {
if (err.code) {
// Process service logic errors.
console.error(`requestDialogService failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('requestDialogService succeed, result = ' + JSON.stringify(result));
});
} catch (err) {
// Process input parameter errors.
console.error(`requestDialogService failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.requestDialogService
requestDialogService(want: Want): Promise&lt;dialogRequest.RequestResult&gt;;
Starts a ServiceExtensionAbility that supports modal dialog boxes. After the ServiceExtensionAbility is started, the application displays a modal dialog box. You can call [setRequestResult](js-apis-app-ability-dialogRequest.md#requestcallbacksetrequestresult) to obtain the result, which is returned to the caller in promise mode.
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 **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 stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ServiceExtensionAbility.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[dialogRequest.RequestResult](js-apis-app-ability-dialogRequest.md)&gt; | Promise used to return the result.
**Example**
```ts
import dialogRequest from '@ohos.app.ability.dialogRequest';
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'AuthAccountServiceExtension'
};
try {
this.context.requestDialogService(want)
.then((result) => {
// Carry out normal service processing.
console.info('requestDialogService succeed, result = ' + JSON.stringify(result));
})
.catch((err) => {
// Process service logic errors.
console.error(`requestDialogService failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
console.error(`requestDialogService failed, code is ${err.code}, message is ${err.message}`);
}
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册