1# @ohos.app.ability.StartOptions (StartOptions) 2 3**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. 4 5> **NOTE** 6> 7> - 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. 8> 9> - The APIs of this module can be used only in the stage model. 10 11## Modules to Import 12 13```ts 14import { StartOptions } from '@kit.AbilityKit'; 15``` 16 17## Properties 18 19**System capability**: SystemCapability.Ability.AbilityRuntime.Core 20 21| Name| Type| Read-only| Optional| Description| 22| -------- | -------- | -------- | -------- | -------- | 23| 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).| 24| 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.| 25| withAnimation<sup>11+</sup> | boolean | No| Yes| Whether animation effects are used when the ability is started. The value **true** means that animation effects are used, and **false** means the opposite.<br>**Constraints**:<br>1. This property takes effect only on 2-in-1 devices and tablets.<br>2. The caller and target must be the same application.| 26| windowLeft<sup>11+</sup> | number | No| Yes| Position of the left edge of the window, in px.| 27| windowTop<sup>11+</sup> | number | No| Yes| Position of the top edge of the window, in px.| 28| windowWidth<sup>11+</sup> | number | No| Yes| Window width, in px.| 29| windowHeight<sup>11+</sup> | number | No| Yes| Window height, in px.| 30| 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 2-in-1 devices and 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.| 31| 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 2-in-1 devices and 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.| 32| 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 2-in-1 devices and tablets.<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.| 33| 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 2-in-1 devices and tablets.<br>2. This property takes effect only in [UIAbilityContext.startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1).| 34| supportWindowModes<sup>14+</sup> | Array\<[bundleManager.SupportWindowMode](./js-apis-bundleManager.md#supportwindowmode)> | No| Yes| Whether to display the maximize, minimize, or split-screen button when the UIAbility is launched in an application. If this property is not set, the value of **supportWindowMode** configured under [abilities](../../quick-start/module-configuration-file.md#abilities) in the [module.json5 file](../../quick-start/module-configuration-file.md) corresponding to the UIAbility is used by default.<br>- **FULL_SCREEN**: full-screen mode.<br>- **FLOATING**: floating window mode.<br>- **SPLIT**: split-screen mode. Generally, **FULL_SCREEN** or **FLOATING** must be used together. You are not advised to configure only **SPLIT**. If only **SPLIT** is configured, the window on 2-in-1 devices is in floating window mode by default and can transition to the split-screen mode, and the window on tablets is in full-screen mode by default and can transition to the split-screen mode.<br>**Constraints**:<br><!--RP1-->This property takes effect only on 2-in-1 devices and tablets.<!--RP1End-->| 35| minWindowWidth<sup>18+</sup> | number | No| Yes| Minimum width of the window, in vp.<br>**Constraints**:<br>This property takes effect only on 2-in-1 devices.| 36| minWindowHeight<sup>18+</sup> | number | No| Yes| Minimum height of the window, in vp.<br>**Constraints**:<br>This property takes effect only on 2-in-1 devices.| 37| maxWindowWidth<sup>18+</sup> | number | No| Yes| Maximum width of the window, in vp.<br>**Constraints**:<br>This property takes effect only on 2-in-1 devices.| 38| maxWindowHeight<sup>18+</sup> | number | No| Yes| Maximum height of the window, in vp.<br>**Constraints**:<br>This property takes effect only on 2-in-1 devices.| 39 40**Example** 41 42 ```ts 43 import { UIAbility, Want, StartOptions, bundleManager } from '@kit.AbilityKit'; 44 import { BusinessError } from '@kit.BasicServicesKit'; 45 import { image } from '@kit.ImageKit'; 46 47 export default class EntryAbility extends UIAbility { 48 onForeground() { 49 let want: Want = { 50 deviceId: '', 51 bundleName: 'com.example.myapplication', 52 abilityName: 'EntryAbility' 53 }; 54 55 let color = new ArrayBuffer(0); 56 let imagePixelMap: image.PixelMap; 57 image.createPixelMap(color, { 58 size: { 59 height: 100, 60 width: 100 61 } 62 }).then((data) => { 63 imagePixelMap = data; 64 let options: StartOptions = { 65 displayId: 0, 66 startWindowIcon: imagePixelMap, 67 startWindowBackgroundColor: '#00000000', 68 supportWindowModes: [ 69 bundleManager.SupportWindowMode.FULL_SCREEN, 70 bundleManager.SupportWindowMode.SPLIT, 71 bundleManager.SupportWindowMode.FLOATING 72 ], 73 minWindowWidth: 320, 74 minWindowHeight: 240, 75 maxWindowWidth: 2560, 76 maxWindowHeight: 2560 77 }; 78 79 try { 80 this.context.startAbility(want, options, (err: BusinessError) => { 81 if (err.code) { 82 // Process service logic errors. 83 console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`); 84 return; 85 } 86 // Carry out normal service processing. 87 console.info('startAbility succeed'); 88 }); 89 } catch (err) { 90 // Process input parameter errors. 91 let code = (err as BusinessError).code; 92 let message = (err as BusinessError).message; 93 console.error(`startAbility failed, code is ${code}, message is ${message}`); 94 } 95 }).catch((err: BusinessError) => { 96 console.error(`createPixelMap failed, code is ${err.code}, message is ${err.message}`); 97 }); 98 } 99 } 100 ``` 101