• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# PageAbility Launch Type
2
3
4Depending on the launch type, the action performed when the PageAbility starts differs, as described in the table below.
5
6**Table 1** PageAbility launch types
7
8| Launch Type| Meaning        | Description|
9| -------- | -------- | -------- |
10| singleton | Singleton mode| Each time **startAbility()** is called, if an ability instance of this type already exists in the application process, the instance is reused. There is only one ability instance of this type in **Recents**.<br>A typical scenario is as follows: When a user opens a video playback application and watches a video, returns to the home screen, and opens the video playback application again, the video that the user watched before returning to the home screen is still played.|
11| standard | Multiton mode| Default type. Each time **startAbility()** is called, a new ability instance is created in the application process. Multiple ability instances of this type are displayed in **Recents**.<br>A typical scenario is as follows: When a user opens a document application and touches **New**, a new document task is created. Multiple new document missions are displayed in **Recents**.|
12
13
14You can set **launchType** in the **config.json** file to configure the launch type. The sample code is as follows:
15
16```json
17{
18  "module": {
19    // ...
20    "abilities": [
21      {
22        // singleton means the singleton mode.
23        // standard means the multiton mode.
24        "launchType": "standard",
25        // ...
26      }
27    ]
28  }
29}
30```
31
32
33When the PageAbility is started in multiton mode or it is started in singleton mode for the first time, the [PageAbility lifecycle callbacks](pageability-lifecycle.md#table13118194914476) are triggered. When it is not started for the first time in singleton mode, the **onNewWant()** callback (as described in the table below) is triggered, but the **onCreate()** callback is not.
34
35
36**Table 2** Callbacks specific to the singleton mode
37
38| API| Description|
39| -------- | -------- |
40| onNewWant(want: Want) | **onNewWant()** is triggered when the PageAbility is not started for the first time in singleton mode. You can obtain Want from this callback and perform further processing based on Want. For example, in the singleton PageAbility migration scenario, you can specify a page to start the PageAbility.|
41