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#uiabilitycontextstartabilitybytype11) or [UIExtensionContentSession.startAbilityByType](../reference/apis-ability-kit/js-apis-app-ability-uiExtensionContentSession.md#uiextensioncontentsessionstartabilitybytype11) 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 let context = getContext(this) as common.UIAbilityContext; 28 let wantParam: Record<string, Object> = { 29 'sceneType': 1, 30 'expressNo': 'SF123456' 31 }; 32 let abilityStartCallback: common.AbilityStartCallback = { 33 onError: (code: number, name: string, message: string) => { 34 console.log(`onError code ${code} name: ${name} message: ${message}`); 35 }, 36 onResult: (result)=>{ 37 console.log(`onResult result: ${JSON.stringify(result)}`); 38 } 39 } 40 41 context.startAbilityByType("express", wantParam, abilityStartCallback, 42 (err) => { 43 if (err) { 44 console.error(`startAbilityByType fail, err: ${JSON.stringify(err)}`); 45 } else { 46 console.log(`success`); 47 } 48 }); 49 50 ``` 51 52 Effect 53 54  55 56## Developing a Target Application 57 581. Configure [uris](../quick-start/module-configuration-file.md#skills) in the **module.json5** file. 59 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: 60 | Value | Description | 61 | ------------ | -------------------- | 62 | QueryExpress | Declares that the application supports express delivery query.| 63 2. Set **scheme**, **host**, **port**, and **path** or **pathStartWith** to match the URIs in Want to distinguish different features. 64 ```json 65 { 66 "abilities": [ 67 { 68 "skills": [ 69 { 70 "uris": [ 71 { 72 "scheme": "express", 73 "host": "queryExpress", 74 "path": "", 75 "linkFeature": "QueryExpress" 76 } 77 ] 78 } 79 ] 80 } 81 ] 82 } 83 ``` 84 852. Parse parameters and perform corresponding processing. 86 87 ```ts 88 UIAbility.onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void 89 ``` 90 91 The **want.uri** parameter carries the URI corresponding to **linkFeature** configured by the target application. 92 93 The **want.parameters** parameter carries the parameters transferred by the caller application, as described in the table below. 94 95 | Name | Type | Mandatory| Description | 96 | --------- | ------ | ---- | -------- | 97 | expressNo | string | Yes | Express delivery tracking number.| 98 99 100 101**Sample Code** 102 103```ts 104import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; 105import { hilog } from '@kit.PerformanceAnalysisKit'; 106import { window } from '@kit.ArkUI'; 107 108const TAG = 'EntryAbility' 109 110export default class EntryAbility extends UIAbility { 111 windowStage: window.WindowStage | null = null; 112 113 uri?: string; 114 expressNo?: string; 115 116 onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { 117 hilog.info(0x0000, TAG, `onCreate, want=${JSON.stringify(want)}`); 118 super.onCreate(want, launchParam); 119 this.parseWant(want); 120 } 121 122 onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { 123 hilog.info(0x0000, TAG, `onNewWant, want=${JSON.stringify(want)}`); 124 super.onNewWant(want, launchParam); 125 this.parseWant(want); 126 if (!this.windowStage) { 127 hilog.error(0x0000, TAG, 'windowStage is null'); 128 this.context.terminateSelf(); 129 return; 130 } 131 this.loadPage(this.windowStage); 132 } 133 134 private parseWant(want: Want): void { 135 this.uri = want.uri as string | undefined; 136 this.expressNo = want.parameters?.expressNo as string | undefined; 137 } 138 139 private loadPage(windowStage: window.WindowStage): void { 140 hilog.info(0x0000, TAG, `loadPage, uri=${this.uri}`); 141 if (this.uri === 'express://queryExpress') { 142 // Build express delivery query parameters. 143 const storage: LocalStorage = new LocalStorage({ 144 "expressNo": this.expressNo 145 } as Record<string, Object>); 146 // Display the express delivery query page. 147 windowStage.loadContent('pages/QueryExpressPage', storage) 148 } else { 149 // Display the home page by default. 150 windowStage.loadContent('pages/Index', (err) => { 151 if (err.code) { 152 hilog.error(0x0000, TAG, 'Failed to load the content. Cause: %{public}s', 153 JSON.stringify(err) ?? ''); 154 return; 155 } 156 hilog.info(0x0000, TAG, 'Succeeded in loading the content.'); 157 }); 158 } 159 } 160 161 onDestroy(): void { 162 hilog.info(0x0000, TAG, `onDestroy`); 163 } 164 165 onWindowStageCreate(windowStage: window.WindowStage): void { 166 hilog.info(0x0000, TAG, `onWindowStageCreate`); 167 this.windowStage = windowStage; 168 this.loadPage(this.windowStage); 169 } 170 171 onWindowStageDestroy(): void { 172 hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageDestroy'); 173 } 174 175 onForeground(): void { 176 hilog.info(0x0000, TAG, '%{public}s', 'Ability onForeground'); 177 } 178 179 onBackground(): void { 180 hilog.info(0x0000, TAG, '%{public}s', 'Ability onBackground'); 181 } 182} 183``` 184