• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Using Implicit Want to Open a Website
2
3
4## Prerequisites
5
6One or more browsers are installed on your device.
7
8The **module.json5** of a browser application is as follows:
9
10```json
11"skills": [
12  {
13    "entities": [
14      "entity.system.browsable"
15      // ...
16    ],
17    "actions": [
18        "ohos.want.action.viewData"
19        // ...
20    ],
21    "uris": [
22      {
23        "scheme": "https",
24        "host": "www.test.com",
25        "port": "8080",
26        // Prefix matching is used.
27        "pathStartWith": "query",
28        "type": "text/*"
29      },
30      {
31        "scheme": "http",
32        // ...
33      }
34      // ...
35    ]
36  },
37]
38```
39
40
41## How to Develop
42
431. Use the custom function **implicitStartAbility** to start an ability.
44
45   ```ts
46       async implicitStartAbility() {
47           try {
48               let want = {
49                   // Uncomment the line below if you want to implicitly query data only in the specific bundle.
50                   // bundleName: "com.example.myapplication",
51                   "action": "ohos.want.action.viewData",
52                   // entities can be omitted.
53                   "entities": [ "entity.system.browsable" ],
54                   "uri": "https://www.test.com:8080/query/student",
55                   "type": "text/plain"
56               }
57               let context = getContext(this) as common.UIAbilityContext;
58               await context.startAbility(want)
59               console.info(`explicit start ability succeed`)
60           } catch (error) {
61               console.info(`explicit start ability failed with ${error.code}`)
62           }
63        }
64   ```
65
66     The matching process is as follows:
67   1. If **action** in the passed **want** parameter is specified and is included in **actions** under **skills**, the matching is successful.
68
69   2. If **entities** in the passed **want** parameter is specified and is included in **entities** under **skills**, the matching is successful.
70
71   3. If **uri** in the passed **want** parameter is included in **uris** under **skills**, which is concatenated into `https://www.test.com:8080/query*` (where \* is a wildcard), the matching is successful.
72
73   4. If **type** in the passed **want** parameter is specified and is included in **type** under **skills**, the matching is successful.
74
752. When there are multiple matching applications, a dialog box is displayed for you to select one of them.
76
77   ![stage-want1](figures/stage-want1.png)
78