1e41f4b71Sopenharmony_ci# UIAbility Usage 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ciWhen using the [UIAbility](../reference/apis-ability-kit/js-apis-app-ability-uiAbility.md) component, you must specify a startup page and obtain the context, [UIAbilityContext](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md). 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci## Specifying the Startup Page of UIAbility 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ciIf no startup page is specified, a white screen occurs after the application is started. You can use [loadContent()](../reference/apis-arkui/js-apis-window.md#loadcontent9) of [WindowStage](../reference/apis-arkui/js-apis-window.md#windowstage9) to set the startup page in the [onWindowStageCreate()](../reference/apis-ability-kit/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate) callback of the [UIAbility](../reference/apis-ability-kit/js-apis-app-ability-uiAbility.md) instance. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci```ts 13e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit'; 14e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI'; 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility { 17e41f4b71Sopenharmony_ci onWindowStageCreate(windowStage: window.WindowStage): void { 18e41f4b71Sopenharmony_ci // Main window is created. Set a main page for this ability. 19e41f4b71Sopenharmony_ci windowStage.loadContent('pages/Index', (err, data) => { 20e41f4b71Sopenharmony_ci // ... 21e41f4b71Sopenharmony_ci }); 22e41f4b71Sopenharmony_ci } 23e41f4b71Sopenharmony_ci // ... 24e41f4b71Sopenharmony_ci} 25e41f4b71Sopenharmony_ci``` 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci> **NOTE** 28e41f4b71Sopenharmony_ci> 29e41f4b71Sopenharmony_ci> When you create UIAbility in DevEco Studio, the UIAbility instance loads the **Index** page as its startup page. Therefore, you only need to replace the **Index** page path with the required startup page path. 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci## Obtaining the Context of UIAbility 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ciThe [UIAbility](../reference/apis-ability-kit/js-apis-app-ability-uiAbility.md) class has its own context, which is an instance of the [UIAbilityContext](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md) class. The [UIAbilityContext](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md) class has attributes such as **abilityInfo** and **currentHapModuleInfo**. UIAbilityContext can be used to obtain the UIAbility configuration information, such as the code path, bundle name, ability name, and environment status required by the application. It can also be used to obtain methods to operate the UIAbility instance, such as [startAbility()](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability), [connectServiceExtensionAbility()](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextconnectserviceextensionability), and [terminateSelf()](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateself). 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ciThe [getContext](../reference/apis-arkui/js-apis-getContext.md#getcontext) API enables you to obtain the context of the ability (either UIAbilityContext or [ExtensionContext](../reference/apis-ability-kit/js-apis-inner-application-extensionContext.md)) on the current page. 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci- You can use **this.context** to obtain the context of a UIAbility instance. 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci ```ts 41e41f4b71Sopenharmony_ci import { UIAbility, AbilityConstant, Want } from '@kit.AbilityKit'; 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci export default class EntryAbility extends UIAbility { 44e41f4b71Sopenharmony_ci onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { 45e41f4b71Sopenharmony_ci // Obtain the context of the UIAbility instance. 46e41f4b71Sopenharmony_ci let context = this.context; 47e41f4b71Sopenharmony_ci // ... 48e41f4b71Sopenharmony_ci } 49e41f4b71Sopenharmony_ci } 50e41f4b71Sopenharmony_ci ``` 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci- Import the context module and define the **context** variable in the component. 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci ```ts 55e41f4b71Sopenharmony_ci import { common, Want } from '@kit.AbilityKit'; 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci @Entry 58e41f4b71Sopenharmony_ci @Component 59e41f4b71Sopenharmony_ci struct Page_EventHub { 60e41f4b71Sopenharmony_ci private context = getContext(this) as common.UIAbilityContext; 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci startAbilityTest(): void { 63e41f4b71Sopenharmony_ci let want: Want = { 64e41f4b71Sopenharmony_ci // Want parameter information. 65e41f4b71Sopenharmony_ci }; 66e41f4b71Sopenharmony_ci this.context.startAbility(want); 67e41f4b71Sopenharmony_ci } 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci // Page display. 70e41f4b71Sopenharmony_ci build() { 71e41f4b71Sopenharmony_ci // ... 72e41f4b71Sopenharmony_ci } 73e41f4b71Sopenharmony_ci } 74e41f4b71Sopenharmony_ci ``` 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci You can also define variables after importing the context module but before using [UIAbilityContext](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md). 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci ```ts 80e41f4b71Sopenharmony_ci import { common, Want } from '@kit.AbilityKit'; 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci @Entry 83e41f4b71Sopenharmony_ci @Component 84e41f4b71Sopenharmony_ci struct Page_UIAbilityComponentsBasicUsage { 85e41f4b71Sopenharmony_ci startAbilityTest(): void { 86e41f4b71Sopenharmony_ci let context = getContext(this) as common.UIAbilityContext; 87e41f4b71Sopenharmony_ci let want: Want = { 88e41f4b71Sopenharmony_ci // Want parameter information. 89e41f4b71Sopenharmony_ci }; 90e41f4b71Sopenharmony_ci context.startAbility(want); 91e41f4b71Sopenharmony_ci } 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci // Page display. 94e41f4b71Sopenharmony_ci build() { 95e41f4b71Sopenharmony_ci // ... 96e41f4b71Sopenharmony_ci } 97e41f4b71Sopenharmony_ci } 98e41f4b71Sopenharmony_ci ``` 99