1# Using startAbilityByType to Start an Express Delivery Application 2 3This topic describes how to open the vertical domain panel of express delivery applications. 4 5For example, in a messaging application, when a user receives a delivery tracking number, the application can identify this number and provide a link for querying the package. After the user touches the link, the application calls [UIAbilityContext.startAbilityByType](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#startabilitybytype11) or [UIExtensionContentSession.startAbilityByType](../reference/apis-ability-kit/js-apis-app-ability-uiExtensionContentSession.md#startabilitybytype11) to open a panel. This panel displays all available applications on the device that support express delivery query, enabling the user to select and switch to the application that meets their needs. 6 7## Parameters on the Express Delivery Application Panel 8 9If the **type** field in **startAbilityByType** is set to **express**, the intent scenario of express delivery query is supported. The corresponding **wantParam** parameter contains the following properties. 10 11 12| Name | Type | Mandatory| Description | 13| --------- | ------ | ---- | -------------------------------------- | 14| sceneType | number | No | Intent scene, which indicates the purpose of the current request. The default value is **1**. In express delivery query scenarios, set it to **1** or leave it empty.| 15| expressNo | string | Yes | Express delivery tracking number. | 16 17 18## Developing a Caller Application 19 201. Import the module. 21 ```ts 22 import { common } from '@kit.AbilityKit'; 23 ``` 242. Construct parameters and call the **startAbilityByType** API. 25 26 ```ts 27 @Entry 28 @Component 29 struct Index { 30 @State hideAbility: string = 'hideAbility'; 31 32 build() { 33 Row() { 34 Column() { 35 Text(this.hideAbility) 36 .fontSize(30) 37 .fontWeight(FontWeight.Bold) 38 .onClick(() => { 39 let context = this.getUIContext().getHostContext() as common.UIAbilityContext; 40 let wantParam: Record<string, Object> = { 41 'sceneType': 1, 42 'expressNo': 'SF123456' 43 }; 44 let abilityStartCallback: common.AbilityStartCallback = { 45 onError: (code: number, name: string, message: string) => { 46 console.log(`onError code ${code} name: ${name} message: ${message}`); 47 }, 48 onResult: (result) => { 49 console.log(`onResult result: ${JSON.stringify(result)}`); 50 } 51 } 52 53 context.startAbilityByType("express", wantParam, abilityStartCallback, 54 (err) => { 55 if (err) { 56 console.error(`startAbilityByType fail, err: ${JSON.stringify(err)}`); 57 } else { 58 console.log(`success`); 59 } 60 }); 61 }); 62 } 63 .width('100%') 64 } 65 .height('100%') 66 } 67 } 68 ``` 69 70 Effect 71  72 73## Developing a Target Application 74 751. Configure [uris](../quick-start/module-configuration-file.md#skills) in the **module.json5** file. 76 1. Set the **linkFeature** field to declare the features supported by the application so that the system can match the application against all the installed applications on the device. The options are as follows: 77 | Value | Description | 78 | ------------ | -------------------- | 79 | QueryExpress | Declares that the application supports express delivery query.| 80 2. Set **scheme**, **host**, **port**, and **path** or **pathStartWith** to match the URIs in Want to distinguish different features. 81 ```json 82 { 83 "abilities": [ 84 { 85 "skills": [ 86 { 87 "uris": [ 88 { 89 "scheme": "express", 90 "host": "queryExpress", 91 "path": "", 92 "linkFeature": "QueryExpress" 93 } 94 ] 95 } 96 ] 97 } 98 ] 99 } 100 ``` 101 1022. Parse parameters and perform corresponding processing. 103 104 ```ts 105 UIAbility.onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void 106 ``` 107 108 The **want.uri** parameter carries the URI corresponding to **linkFeature** configured by the target application. 109 110 The **want.parameters** parameter carries the parameters transferred by the caller application, as described in the table below. 111 112 | Name | Type | Mandatory| Description | 113 | --------- | ------ | ---- | -------- | 114 | expressNo | string | Yes | Express delivery tracking number.| 115 116 117 118**Sample Code** 119 120```ts 121import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; 122import { hilog } from '@kit.PerformanceAnalysisKit'; 123import { window } from '@kit.ArkUI'; 124 125const TAG = 'EntryAbility'; 126 127export default class EntryAbility extends UIAbility { 128 windowStage: window.WindowStage | null = null; 129 130 uri?: string; 131 expressNo?: string; 132 133 onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { 134 hilog.info(0x0000, TAG, `onCreate, want=${JSON.stringify(want)}`); 135 super.onCreate(want, launchParam); 136 this.parseWant(want); 137 } 138 139 onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { 140 hilog.info(0x0000, TAG, `onNewWant, want=${JSON.stringify(want)}`); 141 super.onNewWant(want, launchParam); 142 this.parseWant(want); 143 if (!this.windowStage) { 144 hilog.error(0x0000, TAG, 'windowStage is null'); 145 this.context.terminateSelf(); 146 return; 147 } 148 this.loadPage(this.windowStage); 149 } 150 151 private parseWant(want: Want): void { 152 this.uri = want.uri as string | undefined; 153 this.expressNo = want.parameters?.expressNo as string | undefined; 154 } 155 156 private loadPage(windowStage: window.WindowStage): void { 157 hilog.info(0x0000, TAG, `loadPage, uri=${this.uri}`); 158 if (this.uri === 'express://queryExpress') { 159 // Build express delivery query parameters. 160 const storage: LocalStorage = new LocalStorage({ 161 "expressNo": this.expressNo 162 } as Record<string, Object>); 163 // Display the express delivery query page. 164 windowStage.loadContent('pages/QueryExpressPage', storage) 165 } else { 166 // Display the home page by default. 167 windowStage.loadContent('pages/Index', (err) => { 168 if (err.code) { 169 hilog.error(0x0000, TAG, 'Failed to load the content. Cause: %{public}s', 170 JSON.stringify(err) ?? ''); 171 return; 172 } 173 hilog.info(0x0000, TAG, 'Succeeded in loading the content.'); 174 }); 175 } 176 } 177 178 onDestroy(): void { 179 hilog.info(0x0000, TAG, `onDestroy`); 180 } 181 182 onWindowStageCreate(windowStage: window.WindowStage): void { 183 hilog.info(0x0000, TAG, `onWindowStageCreate`); 184 this.windowStage = windowStage; 185 this.loadPage(this.windowStage); 186 } 187 188 onWindowStageDestroy(): void { 189 hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageDestroy'); 190 } 191 192 onForeground(): void { 193 hilog.info(0x0000, TAG, '%{public}s', 'Ability onForeground'); 194 } 195 196 onBackground(): void { 197 hilog.info(0x0000, TAG, '%{public}s', 'Ability onBackground'); 198 } 199} 200``` 201