提交 41882a61 编写于 作者: G Gloria

Update docs against 21708+21192

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 5c1d5a17
......@@ -1732,7 +1732,7 @@ Creates an array of **PixelMap** objects based on the default parameters. This A
**Example**
```js
imageSourceApi.createPixelMap( pixelmaplist => {
imageSourceApi.createPixelMapList( pixelmaplist => {
console.info('Succeeded in creating pixelmaplist object.');
})
```
......@@ -1763,14 +1763,14 @@ let decodeOpts = {
desiredPixelFormat: 3,
index: 0,
};
imageSourceApi.createPixelMap(decodeOpts, pixelmaplist => {
imageSourceApi.createPixelMapList(decodeOpts, pixelmaplist => {
console.log('Succeeded in creating pixelmaplist object.');
})
```
### getDelayTime<sup>10+</sup>
### getDelayTimeList<sup>10+</sup>
getDelayTime(callback: AsyncCallback<Array\<number>>): void;
getDelayTimeList(callback: AsyncCallback<Array\<number>>): void;
Obtains an array of delay times. This API uses an asynchronous callback to return the result.
......@@ -1785,14 +1785,14 @@ Obtains an array of delay times. This API uses an asynchronous callback to retur
**Example**
```js
imageSourceApi.getDelayTime( delayTimes => {
imageSourceApi.getDelayTimeList( delayTimes => {
console.log('Succeeded in getting delay time.');
});
```
### getDelayTime<sup>10+</sup>
### getDelayTimeList<sup>10+</sup>
getDelayTime(): Promise<Array\<number>>;
getDelayTimeList(): Promise<Array\<number>>;
Obtains an array of delay times. This API uses a promise to return the result.
......@@ -1807,7 +1807,7 @@ Obtains an array of delay times. This API uses a promise to return the result.
**Example**
```js
let delayTimes = imageSourceApi.getDelayTime();
let delayTimes = imageSourceApi.getDelayTimeList();
```
### getFrameCount<sup>10+</sup>
......@@ -2839,9 +2839,9 @@ Defines image decoding options.
| Name | Type | Readable| Writable| Description |
| ------------------ | ---------------------------------- | ---- | ---- | ---------------- |
| sampleSize | number | Yes | Yes | Thumbnail sampling size.|
| sampleSize | number | Yes | Yes | Thumbnail sampling size. Currently, this option can only be set to **1**.|
| rotate | number | Yes | Yes | Rotation angle. |
| editable | boolean | Yes | Yes | Whether the image is editable. |
| editable | boolean | Yes | Yes | Whether the image is editable. If this option is set to **false**, the image cannot be edited again, and operations such as cropping will fail. |
| desiredSize | [Size](#size) | Yes | Yes | Expected output size. |
| desiredRegion | [Region](#region7) | Yes | Yes | Region to decode. |
| desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format for decoding.|
......@@ -2899,34 +2899,34 @@ Describes the exchangeable image file format (EXIF) data of an image.
| GPS_LONGITUDE | "GPSLongitude" | Image longitude. |
| GPS_LATITUDE_REF | "GPSLatitudeRef" | Latitude reference, for example, N or S. |
| GPS_LONGITUDE_REF | "GPSLongitudeRef" | Longitude reference, for example, W or E. |
| DATE_TIME_ORIGINAL<sup>9+</sup> | "DateTimeOriginal" | Shooting time, for example, 2022:09:06 15:48:00. |
| EXPOSURE_TIME<sup>9+</sup> | "ExposureTime" | Exposure time, for example, 1/33 sec.|
| SCENE_TYPE<sup>9+</sup> | "SceneType" | Shooting scene type, for example, portrait, scenery, motion, and night. |
| ISO_SPEED_RATINGS<sup>9+</sup> | "ISOSpeedRatings" | ISO sensitivity or ISO speed, for example, 400. |
| F_NUMBER<sup>9+</sup> | "FNumber" | Aperture, for example, f/1.8. |
| DATE_TIME<sup>10+</sup> | "DateTime" | Date and time. |
| GPS_TIME_STAMP<sup>10+</sup> | "GPSTimeStamp" | GPS timestamp. |
| GPS_DATE_STAMP<sup>10+</sup> | "GPSDateStamp" | GPS date stamp. |
| IMAGE_DESCRIPTION<sup>10+</sup> | "ImageDescription" | Image description. |
| MAKE<sup>10+</sup> | "Make" | Vendor. |
| PHOTO_MODE<sup>10+</sup> | "PhotoMode " | Photo mode. |
| SENSITIVITY_TYPE<sup>10+</sup> | "SensitivityType" | Sensitivity type. |
| STANDARD_OUTPUT_SENSITIVITY<sup>10+</sup> | "StandardOutputSensitivity" | Standard output sensitivity. |
| RECOMMENDED_EXPOSURE_INDEX<sup>10+</sup> | "RecommendedExposureIndex" | Recommended exposure index. |
| ISO_SPEED<sup>10+</sup> | "ISOSpeedRatings" | ISO speed. |
| APERTURE_VALUE<sup>10+</sup> | "ApertureValue" | Aperture value. |
| EXPOSURE_BIAS_VALUE<sup>10+</sup> | "ExposureBiasValue" | Exposure bias value. |
| METERING_MODE<sup>10+</sup> | "MeteringMode" | Metering mode. |
| LIGHT_SOURCE<sup>10+</sup> | "LightSource" | Light source. |
| FLASH <sup>10+</sup> | "Flash" | Flash status. |
| FOCAL_LENGTH <sup>10+</sup> | "FocalLength" | Focal length. |
| USER_COMMENT <sup>10+</sup> | "UserComment" | User comment. |
| PIXEL_X_DIMENSION <sup>10+</sup> | "PixelXDimension" | Pixel X dimension. |
| PIXEL_Y_DIMENSION<sup>10+</sup> | "PixelYDimension" | Pixel Y dimension. |
| WHITE_BALANCE <sup>10+</sup> | "WhiteBalance" | White balance. |
| FOCAL_LENGTH_IN_35_MM_FILM <sup>10+</sup> | "FocalLengthIn35mmFilm" | Focal length in 35mm film. |
| CAPTURE_MODE <sup>10+</sup> | "HwMnoteCaptureMode" | Capture mode. |
| PHYSICAL_APERTURE <sup>10+</sup> | "HwMnotePhysicalAperture" | Physical aperture. |
| DATE_TIME_ORIGINAL<sup>9+</sup> | "DateTimeOriginal" | Shooting time, for example, 2022:09:06 15:48:00. This attribute is read-only. |
| EXPOSURE_TIME<sup>9+</sup> | "ExposureTime" | Exposure time, for example, 1/33 sec. Currently, this attribute is read-only.|
| SCENE_TYPE<sup>9+</sup> | "SceneType" | Shooting scene type, for example, portrait, scenery, motion, and night. Currently, this attribute is read-only. |
| ISO_SPEED_RATINGS<sup>9+</sup> | "ISOSpeedRatings" | ISO sensitivity or ISO speed, for example, 400. Currently, this attribute is read-only. |
| F_NUMBER<sup>9+</sup> | "FNumber" | Aperture, for example, f/1.8. Currently, this attribute is read-only. |
| DATE_TIME<sup>10+</sup> | "DateTime" | Date and time. Currently, this attribute is read-only. |
| GPS_TIME_STAMP<sup>10+</sup> | "GPSTimeStamp" | GPS timestamp. Currently, this parameter is read-only. |
| GPS_DATE_STAMP<sup>10+</sup> | "GPSDateStamp" | GPS date stamp. Currently, this attribute is read-only. |
| IMAGE_DESCRIPTION<sup>10+</sup> | "ImageDescription" | Image description. Currently, this attribute is read-only. |
| MAKE<sup>10+</sup> | "Make" | Vendor. Currently, this attribute is read-only. |
| PHOTO_MODE<sup>10+</sup> | "PhotoMode " | Photo mode. Currently, this attribute is read-only. |
| SENSITIVITY_TYPE<sup>10+</sup> | "SensitivityType" | Sensitivity type. Currently, this attribute is read-only. |
| STANDARD_OUTPUT_SENSITIVITY<sup>10+</sup> | "StandardOutputSensitivity" | Standard output sensitivity. Currently, this attribute is read-only. |
| RECOMMENDED_EXPOSURE_INDEX<sup>10+</sup> | "RecommendedExposureIndex" | Recommended exposure index. Currently, this attribute is read-only. |
| ISO_SPEED<sup>10+</sup> | "ISOSpeedRatings" | ISO speed. Currently, this attribute is read-only. |
| APERTURE_VALUE<sup>10+</sup> | "ApertureValue" | Aperture value. Currently, this attribute is read-only. |
| EXPOSURE_BIAS_VALUE<sup>10+</sup> | "ExposureBiasValue" | Exposure bias value. Currently, this attribute is read-only. |
| METERING_MODE<sup>10+</sup> | "MeteringMode" | Metering mode. Currently, this attribute is read-only. |
| LIGHT_SOURCE<sup>10+</sup> | "LightSource" | Light source. Currently, this attribute is read-only. |
| FLASH <sup>10+</sup> | "Flash" | Flash status. Currently, this attribute is read-only. |
| FOCAL_LENGTH <sup>10+</sup> | "FocalLength" | Focal length. Currently, this attribute is read-only. |
| USER_COMMENT <sup>10+</sup> | "UserComment" | User comment. Currently, this attribute is read-only. |
| PIXEL_X_DIMENSION <sup>10+</sup> | "PixelXDimension" | Pixel X dimension. Currently, this attribute is read-only. |
| PIXEL_Y_DIMENSION<sup>10+</sup> | "PixelYDimension" | Pixel Y dimension. Currently, this attribute is read-only. |
| WHITE_BALANCE <sup>10+</sup> | "WhiteBalance" | White balance. Currently, this attribute is read-only. |
| FOCAL_LENGTH_IN_35_MM_FILM <sup>10+</sup> | "FocalLengthIn35mmFilm" | Focal length in 35mm film. Currently, this attribute is read-only. |
| CAPTURE_MODE <sup>10+</sup> | "HwMnoteCaptureMode" | Capture mode. Currently, this parameter is read-only. |
| PHYSICAL_APERTURE <sup>10+</sup> | "HwMnotePhysicalAperture" | Physical aperture. Currently, this parameter is read-only. |
## ImageFormat<sup>9+</sup>
......
......@@ -734,6 +734,234 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
}
```
## ServiceExtensionContext.startAbilityAsCaller<sup>10+<sup>
starAbilityAsCaller(want: Want, callback: AsyncCallback<void>): void;
Starts an ability with the caller information specified. The caller information is carried in **want** and identified at the system service layer. The ability can obtain the caller information from the **want** parameter in the **onCreate** lifecycle callback. When this API is used to start an ability, the caller information carried in **want** is not overwritten by the current application information. The system service layer can obtain the initial caller information. This API uses an asynchronous callback to return 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 **exported** 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
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the ability is started, **err** is **undefined**. Otherwise, **err** is an error object.|
**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. |
| 16000012 | The application is controlled. |
| 16000013 | The application is controlled by EDM. |
| 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. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
import extension from '@ohos.app.ability.ServiceExtensionAbility';
import Want from '@ohos.app.ability.Want';
export default class EntryAbility extends extension {
onCreate(want, launchParam) {
// want contains the information about the caller who starts the application.
let localWant: Want = want;
localWant.bundleName = 'com.example.demo';
localWant.moduleName = 'entry';
localWant.abilityName = 'TestAbility';
// Start a new ability using the caller information.
this.context.startAbilityAsCaller(localWant, (err) => {
if (err && err.code != 0) {
console.error('startAbilityAsCaller failed, err:' + JSON.stringify(err));
} else {
console.log('startAbilityAsCaller success.');
}
})
}
}
```
## UIAbiliServiceExtensionContexttyContext.startAbilityAsCaller<sup>10+<sup>
startAbilityAsCaller(want: Want, options: StartOptions, callback: AsyncCallback<void>): void;
Starts an ability with the caller information and start options specified. The caller information is carried in **want** and identified at the system service layer. The ability can obtain the caller information from the **want** parameter in the **onCreate** lifecycle callback. When this API is used to start an ability, the caller information carried in **want** is not overwritten by the current application information. The system service layer can obtain the initial caller information. This API uses an asynchronous callback to return 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 **exported** 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
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the ability is started, **err** is **undefined**. Otherwise, **err** is an error object.|
**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. |
| 16000012 | The application is controlled. |
| 16000013 | The application is controlled by EDM. |
| 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. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
import extension from '@ohos.app.ability.ServiceExtensionAbility';
import Want from '@ohos.app.ability.Want';
export default class EntryAbility extends extension {
onCreate(want, launchParam) {
// want contains the information about the caller who starts the application.
let localWant: Want = want;
localWant.bundleName = 'com.example.demo';
localWant.moduleName = 'entry';
localWant.abilityName = 'TestAbility';
let option: StartOptions = {
displayId: 0
}
// Start a new ability using the caller information.
this.context.startAbilityAsCaller(localWant, option, (err) => {
if (err && err.code != 0) {
console.error('startAbilityAsCaller failed, err:' + JSON.stringify(err));
} else {
console.log('startAbilityAsCaller success.');
}
})
}
}
```
## ServiceExtensionContext.startAbilityAsCaller<sup>10+<sup>
startAbilityAsCaller(want: Want, options?: StartOptions): Promise<void>;
Starts an ability with the caller information specified. The caller information is carried in **want** and identified at the system service layer. The ability can obtain the caller information from the **want** parameter in the **onCreate** lifecycle callback. When this API is used to start an ability, the caller information carried in **want** is not overwritten by the current application information. The system service layer can obtain the initial caller information. This API uses a promise to return 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 **exported** 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
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Parameters used for starting the ability.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**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. |
| 16000012 | The application is controlled. |
| 16000013 | The application is controlled by EDM. |
| 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. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
import extension from '@ohos.app.ability.ServiceExtensionAbility';
import Want from '@ohos.app.ability.Want';
export default class EntryAbility extends extension {
onCreate(want, launchParam) {
// want contains the information about the caller who starts the application.
let localWant: Want = want;
localWant.bundleName = 'com.example.demo';
localWant.moduleName = 'entry';
localWant.abilityName = 'TestAbility';
let option: StartOptions = {
displayId: 0
}
// Start a new ability using the caller information.
this.context.startAbilityAsCaller(localWant, option)
.then(() => {
console.log('startAbilityAsCaller success.');
})
.catch((err) => {
console.error('startAbilityAsCaller failed, err:' + JSON.stringify(err));
})
}
}
```
## ServiceExtensionContext.stopServiceExtensionAbility
stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
......@@ -1324,7 +1552,7 @@ Observe the following when using this API:
- If **exported** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- The rules for using this API in the same-device and cross-device scenarios are different. For details, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Required permissions**: ohos.permission.ABILITY_BACKGROUND_COMMUNICATION
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -1638,7 +1866,7 @@ Observe the following when using this API:
- If **exported** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- The rules for using this API in the same-device and cross-device scenarios are different. For details, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**Required permissions**: ohos.permission.ABILITY_BACKGROUND_COMMUNICATION and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
......@@ -37,6 +37,7 @@ 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 **exported** 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).
- If the ability to start is in another mission stack and the result needs to be returned to the caller, set the **want** parameter by following the description provided in [Want](js-apis-app-ability-want.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -44,7 +45,7 @@ Observe the following when using this API:
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| want | [Want](js-apis-app-ability-want.md) | Yes| Want information about the target ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
......@@ -1700,7 +1701,7 @@ Observe the following when using this API:
- If **exported** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- The rules for using this API in the same-device and cross-device scenarios are different. For details, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Required permissions**: ohos.permission.ABILITY_BACKGROUND_COMMUNICATION
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -2719,7 +2720,7 @@ Observe the following when using this API:
- If **exported** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- The rules for using this API in the same-device and cross-device scenarios are different. For details, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**Required permissions**: ohos.permission.ABILITY_BACKGROUND_COMMUNICATION and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -2792,6 +2793,228 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
}
```
## UIAbilityContext.startAbilityAsCaller<sup>10+<sup>
starAbilityAsCaller(want: Want, callback: AsyncCallback<void>): void;
Starts an ability with the caller information specified. The caller information is carried in **want** and identified at the system service layer. The ability can obtain the caller information from the **want** parameter in the **onCreate** lifecycle callback. When this API is used to start an ability, the caller information carried in **want** is not overwritten by the current application information. The system service layer can obtain the initial caller information. This API uses an asynchronous callback to return 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 **exported** 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 ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the ability is started, **err** is **undefined**. Otherwise, **err** is an error object.|
**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. |
| 16000012 | The application is controlled. |
| 16000013 | The application is controlled by EDM. |
| 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. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import Want from '@ohos.app.ability.Want';
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
// want contains the information about the caller who starts the application.
let localWant: Want = want;
localWant.bundleName = 'com.example.demo';
localWant.moduleName = 'entry';
localWant.abilityName = 'TestAbility';
// Start a new ability using the caller information.
this.context.startAbilityAsCaller(localWant, (err) => {
if (err && err.code != 0) {
console.error('startAbilityAsCaller failed, err:' + JSON.stringify(err));
} else {
console.log('startAbilityAsCaller success.');
}
})
}
}
```
## UIAbilityContext.startAbilityAsCaller<sup>10+<sup>
startAbilityAsCaller(want: Want, options: StartOptions, callback: AsyncCallback<void>): void;
Starts an ability with the caller information and start options specified. The caller information is carried in **want** and identified at the system service layer. The ability can obtain the caller information from the **want** parameter in the **onCreate** lifecycle callback. When this API is used to start an ability, the caller information carried in **want** is not overwritten by the current application information. The system service layer can obtain the initial caller information. This API uses an asynchronous callback to return 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 **exported** 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 ability.|
| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the ability is started, **err** is **undefined**. Otherwise, **err** is an error object.|
**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. |
| 16000012 | The application is controlled. |
| 16000013 | The application is controlled by EDM. |
| 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. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import Want from '@ohos.app.ability.Want';
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
// want contains the information about the caller who starts the application.
let localWant: Want = want;
localWant.bundleName = 'com.example.demo';
localWant.moduleName = 'entry';
localWant.abilityName = 'TestAbility';
let option: StartOptions = {
displayId: 0
}
// Start a new ability using the caller information.
this.context.startAbilityAsCaller(localWant, option, (err) => {
if (err && err.code != 0) {
console.error('startAbilityAsCaller failed, err:' + JSON.stringify(err));
} else {
console.log('startAbilityAsCaller success.');
}
})
}
}
```
## UIAbilityContext.startAbilityAsCaller<sup>10+<sup>
startAbilityAsCaller(want: Want, options?: StartOptions): Promise<void>;
Starts an ability with the caller information specified. The caller information is carried in **want** and identified at the system service layer. The ability can obtain the caller information from the **want** parameter in the **onCreate** lifecycle callback. When this API is used to start an ability, the caller information carried in **want** is not overwritten by the current application information. The system service layer can obtain the initial caller information. This API uses a promise to return 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 **exported** 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 ability.|
| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Parameters used for starting the ability.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**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. |
| 16000012 | The application is controlled. |
| 16000013 | The application is controlled by EDM. |
| 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. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import Want from '@ohos.app.ability.Want';
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
// want contains the information about the caller who starts the application.
let localWant: Want = want;
localWant.bundleName = 'com.example.demo';
localWant.moduleName = 'entry';
localWant.abilityName = 'TestAbility';
let option: StartOptions = {
displayId: 0
}
// Start a new ability using the caller information.
this.context.startAbilityAsCaller(localWant, option)
.then(() => {
console.log('startAbilityAsCaller success.');
})
.catch((err) => {
console.error('startAbilityAsCaller failed, err:' + JSON.stringify(err));
})
}
}
```
## UIAbilityContext.reportDrawnCompleted<sup>10+</sup>
reportDrawnCompleted(callback: AsyncCallback\<void>): void;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册