# LaunchUIAbility **Repository Path**: harmonyos_codelabs/LaunchUIAbility ## Basic Information - **Project Name**: LaunchUIAbility - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 5 - **Created**: 2025-07-07 - **Last Updated**: 2026-01-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Starting UIAbility in the Same Application ## Overview This sample demonstrates how to start a UIAbility instance by setting its launch mode and configuring custom parameters in the Want object. This setup determines whether to create a UIAbility instance or reuse an existing one. Creating a UIAbility instance triggers the full lifecycle, while reusing a UIAbility instance triggers the onNewWant callback, where you can perform actions like resetting to a specified page. ## Preview ![launch_type_en.gif](screenshots/device/launch_type_en.gif) ## How to Use 1. On the home page, tap document A to open its UIAbility instance in a new window. 2. Return to the home page and tap document A again to reuse and bring forward the existing UIAbility instance of document A. 3. On the home page, tap the Add button at the bottom to open a new UIAbility instance in a new window. ## Project Directory ``` ├──entry/src/main/ets/ │ ├──abilitystage │ │ └──SpecifiedAbilityStage.ets // Component Container │ ├──entryability │ │ └──EntryAbility.ets // Entry ability │ ├──entrybackupability │ │ └──EntryBackupAbility.ets // Backup and restoration │ ├──model │ │ └──DataModel.ets // DataModel operation │ ├──pages │ │ └──Index.ets // Home page │ ├──specifiedability │ │ └──SpecifiedAbility.ets // Specify page entry │ └──specifiedpages │ └──SpecifiedPage.ets // Specify page └──entry/src/main/resources // Application resource directory ``` ## How to Implement With the launch mode set to a specific type, tapping a document in the list or the Add button works as follows: - Tapping document A on the home page triggers [startAbility()](https://developer.huawei.com/consumer/en/doc/harmonyos-references/js-apis-inner-application-uiabilitycontext#startability) with a custom parameter in the Want object. This parameter is passed to the [onAcceptWant()](https://developer.huawei.com/consumer/en/doc/harmonyos-references/js-apis-app-ability-abilitystage#onacceptwant) method as a key, leading to the creation of a UIAbility instance for document A. - Returning to the home page and tapping document A again triggers startAbility(). The onAcceptWant() method checks if the key matches. If it matches, the existing UIAbility instance is reused and brought forward; otherwise, a UIAbility instance is created. - Tapping the Add button on the home page triggers startAbility() without a custom parameter in the Want object. Each tap creates and opens a new UIAbility instance. ## Permissions N/A ## Dependency N/A ## Constraints 1. This sample is only supported on Huawei phones running standard systems. 2. The HarmonyOS version must be HarmonyOS 5.1.1 Release or later. 3. The DevEco Studio version must be DevEco Studio 6.0.2 Release or later. 4. The HarmonyOS SDK version must be HarmonyOS 6.0.2 Release SDK or later.