1e41f4b71Sopenharmony_ci# @ohos.app.ability.StartOptions (StartOptions) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci**StartOptions** is used as an input parameter of [startAbility()](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1) to specify the window mode of an ability. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> - 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. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> - The APIs of this module can be used only in the stage model. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## Modules to Import 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci```ts 14e41f4b71Sopenharmony_ciimport { StartOptions } from '@kit.AbilityKit'; 15e41f4b71Sopenharmony_ci``` 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## Properties 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci| Name| Type| Read-only| Optional| Description| 22e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 23e41f4b71Sopenharmony_ci| windowMode<sup>12+<sup> | number | No| Yes| Window mode when the ability is started. For details, see [WindowMode](./js-apis-app-ability-abilityConstant.md#windowmode12).| 24e41f4b71Sopenharmony_ci| displayId | number | No| Yes| Display ID mode. The default value is **0**, indicating the current display.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 25e41f4b71Sopenharmony_ci| withAnimation<sup>11+</sup> | boolean | No| Yes| Whether the ability has the animation effect.| 26e41f4b71Sopenharmony_ci| windowLeft<sup>11+</sup> | number | No| Yes| Left position of the window.| 27e41f4b71Sopenharmony_ci| windowTop<sup>11+</sup> | number | No| Yes| Top position of the window.| 28e41f4b71Sopenharmony_ci| windowWidth<sup>11+</sup> | number | No| Yes| Width of the window.| 29e41f4b71Sopenharmony_ci| windowHeight<sup>11+</sup> | number | No| Yes| Height of the window.| 30e41f4b71Sopenharmony_ci| processMode<sup>12+</sup> | [contextConstant.ProcessMode](js-apis-app-ability-contextConstant.md#processmode12) | No| Yes| Process mode.<br>**Constraints**:<br>1. This property takes effect only on tablets.<br>2. This property takes effect only in [UIAbilityContext.startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1).<br>3. **processMode** and **startupVisibility** must be set in pair.| 31e41f4b71Sopenharmony_ci| startupVisibility<sup>12+</sup> | [contextConstant.StartupVisibility](js-apis-app-ability-contextConstant.md#startupvisibility12) | Yes| No| Visibility of the ability after it is started.<br>**Constraints**:<br>1. This property takes effect only on tablets.<br>2. This property takes effect only in [UIAbilityContext.startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1).<br>3. **processMode** and **startupVisibility** must be set in pair.| 32e41f4b71Sopenharmony_ci| startWindowIcon<sup>14+</sup> | [image.PixelMap](../../reference/apis-image-kit/js-apis-image.md#pixelmap7) | No| Yes| Icon displayed on the launch page when the UIAbility is started in an application. If this property is not set, the value of **startWindowIcon** in the **module.json5** file is used by default.<br>**Constraints**:<br>1. This property takes effect only on tablets and 2-in-1 devices.<br>2. This property takes effect only in [UIAbilityContext.startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1).<br>3. The maximum size of an image is 600 MB.| 33e41f4b71Sopenharmony_ci| startWindowBackgroundColor<sup>14+</sup> | string | No| Yes| Background color of the launch page when the UIAbility is launched in an application. If this property is not set, the value of **startWindowBackground** in the **module.json5** file is used by default.<br>**Constraints**:<br>1. This property takes effect only on tablets and 2-in-1 devices.<br>2. This property takes effect only in [UIAbilityContext.startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1).| 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci**Example** 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci ```ts 38e41f4b71Sopenharmony_ci import { UIAbility, Want, StartOptions } from '@kit.AbilityKit'; 39e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 40e41f4b71Sopenharmony_ci import { image } from '@kit.ImageKit'; 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci export default class EntryAbility extends UIAbility { 43e41f4b71Sopenharmony_ci onForeground() { 44e41f4b71Sopenharmony_ci let want: Want = { 45e41f4b71Sopenharmony_ci deviceId: '', 46e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 47e41f4b71Sopenharmony_ci abilityName: 'EntryAbility' 48e41f4b71Sopenharmony_ci }; 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci let color = new ArrayBuffer(0); 51e41f4b71Sopenharmony_ci let imagePixelMap: image.PixelMap; 52e41f4b71Sopenharmony_ci image.createPixelMap(color, { 53e41f4b71Sopenharmony_ci size: { 54e41f4b71Sopenharmony_ci height: 100, 55e41f4b71Sopenharmony_ci width: 100 56e41f4b71Sopenharmony_ci } 57e41f4b71Sopenharmony_ci }).then((data) => { 58e41f4b71Sopenharmony_ci imagePixelMap = data; 59e41f4b71Sopenharmony_ci let options: StartOptions = { 60e41f4b71Sopenharmony_ci displayId: 0, 61e41f4b71Sopenharmony_ci startWindowIcon: imagePixelMap, 62e41f4b71Sopenharmony_ci startWindowBackgroundColor: '#00000000' 63e41f4b71Sopenharmony_ci }; 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci try { 66e41f4b71Sopenharmony_ci this.context.startAbility(want, options, (err: BusinessError) => { 67e41f4b71Sopenharmony_ci if (err.code) { 68e41f4b71Sopenharmony_ci // Process service logic errors. 69e41f4b71Sopenharmony_ci console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`); 70e41f4b71Sopenharmony_ci return; 71e41f4b71Sopenharmony_ci } 72e41f4b71Sopenharmony_ci // Carry out normal service processing. 73e41f4b71Sopenharmony_ci console.info('startAbility succeed'); 74e41f4b71Sopenharmony_ci }); 75e41f4b71Sopenharmony_ci } catch (err) { 76e41f4b71Sopenharmony_ci // Process input parameter errors. 77e41f4b71Sopenharmony_ci let code = (err as BusinessError).code; 78e41f4b71Sopenharmony_ci let message = (err as BusinessError).message; 79e41f4b71Sopenharmony_ci console.error(`startAbility failed, code is ${code}, message is ${message}`); 80e41f4b71Sopenharmony_ci } 81e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 82e41f4b71Sopenharmony_ci console.error(`createPixelMap failed, code is ${err.code}, message is ${err.message}`); 83e41f4b71Sopenharmony_ci }); 84e41f4b71Sopenharmony_ci } 85e41f4b71Sopenharmony_ci } 86e41f4b71Sopenharmony_ci ``` 87