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