1# @ohos.bundle.defaultAppManager (Default Application Management)
2
3The **DefaultAppManager** module provides APIs to query whether the current application is the default application of a specific type.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```ts
12import { defaultAppManager } from '@kit.AbilityKit';
13```
14
15## defaultAppManager.ApplicationType
16
17Enumerates the default application types.
18
19**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp
20
21| Name  | Value | Description                                  |
22| -------- | -------------------------------------- | -------------------------------------- |
23| BROWSER  | 'Web Browser' | Default browser.                           |
24| IMAGE    | 'Image Gallery' | Default image viewer.                        |
25| AUDIO    | 'Audio Player' | Default audio player.                        |
26| VIDEO    | 'Video Player' | Default video player.                        |
27| PDF      | 'PDF Viewer' | Default PDF reader.                     |
28| WORD     | 'Word Viewer' | Default Word viewer.                    |
29| EXCEL    | 'Excel Viewer' | Default Excel viewer.                   |
30| PPT      | 'PPT Viewer' | Default PowerPoint viewer.                     |
31| EMAIL<sup>12+</sup>    | 'Email' | Default email.                     |
32
33## defaultAppManager.isDefaultApplication
34
35isDefaultApplication(type: string): Promise\<boolean>
36
37Checks whether this application is the default application of a system-defined application type or a [uniform data type](../apis-arkdata/js-apis-data-uniformTypeDescriptor.md). This API uses a promise to return the result.
38
39**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp
40
41**Parameters**
42
43| Name        | Type    | Mandatory  | Description                                     |
44| ----------- | ------ | ---- | --------------------------------------- |
45| type  | string | Yes   | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmanagerapplicationtype) or [UniformDataType](../apis-arkdata/js-apis-data-uniformTypeDescriptor.md).                          |
46
47**Return value**
48
49| Type                       | Description                |
50| ------------------------- | ------------------ |
51| Promise\<boolean> | Promise used to return the result. If the application is the default application, **true** is returned; otherwise, **false** is returned. |
52
53**Error codes**
54
55For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
56
57| ID | Error Message                                                   |
58| -------- | ---------------------------------------------------------- |
59| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
60| 801 | Capability not supported. |
61
62**Example**
63
64```ts
65import { defaultAppManager } from '@kit.AbilityKit';
66import { BusinessError } from '@kit.BasicServicesKit';
67
68defaultAppManager.isDefaultApplication(defaultAppManager.ApplicationType.BROWSER)
69  .then((data) => {
70    console.info('Operation successful. IsDefaultApplication ? ' + JSON.stringify(data));
71  }).catch((error: BusinessError) => {
72    console.error('Operation failed. Cause: ' + JSON.stringify(error));
73  });
74```
75
76## defaultAppManager.isDefaultApplication
77
78isDefaultApplication(type: string, callback: AsyncCallback\<boolean>): void
79
80Checks whether this application is the default application of a system-defined application type or a [uniform data type](../apis-arkdata/js-apis-data-uniformTypeDescriptor.md). This API uses an asynchronous callback to return the result.
81
82**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp
83
84**Parameters**
85
86| Name        | Type                             | Mandatory  | Description                                     |
87| ----------- | ------------------------------- | ---- | --------------------------------------- |
88| type  | string                          | Yes   | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmanagerapplicationtype) or [UniformDataType](../apis-arkdata/js-apis-data-uniformTypeDescriptor.md).                           |
89| callback    | AsyncCallback\<boolean> | Yes   | Callback used to return the result. If the application is the default application, **true** is returned; otherwise, **false** is returned. |
90
91**Error codes**
92
93For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
94
95| ID | Error Message                                                   |
96| -------- | ---------------------------------------------------------- |
97| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
98| 801 | Capability not supported. |
99
100**Example**
101
102```ts
103import { defaultAppManager } from '@kit.AbilityKit';
104import { BusinessError } from '@kit.BasicServicesKit';
105
106defaultAppManager.isDefaultApplication(defaultAppManager.ApplicationType.BROWSER, (err: BusinessError, data) => {
107  if (err) {
108    console.error('Operation failed. Cause: ' + JSON.stringify(err));
109    return;
110  }
111  console.info('Operation successful. IsDefaultApplication ? ' + JSON.stringify(data));
112});
113```
114
115## defaultAppManager.isDefaultApplicationSync<sup>10+</sup>
116
117isDefaultApplicationSync(type: string): boolean
118
119Checks whether this application is the default application of a system-defined application type or a [uniform data type](../apis-arkdata/js-apis-data-uniformTypeDescriptor.md). This API returns the result synchronously.
120
121**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp
122
123**Parameters**
124
125| Name | Type  | Mandatory | Description                                    |
126| -------| ------ | ---- | --------------------------------------- |
127|  type  | string | Yes  | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmanagerapplicationtype) or [UniformDataType](../apis-arkdata/js-apis-data-uniformTypeDescriptor.md).  |
128
129**Return value**
130
131| Type   | Description                |
132| ------- | -------------------- |
133| boolean | Returns **true** if the application is the default application; returns **false** otherwise. |
134
135**Error codes**
136
137For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
138
139| ID | Error Message                                                   |
140| -------- | ---------------------------------------------------------- |
141| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
142| 801 | Capability not supported. |
143
144**Example**
145
146```ts
147import { defaultAppManager } from '@kit.AbilityKit';
148
149try {
150  let data = defaultAppManager.isDefaultApplicationSync(defaultAppManager.ApplicationType.BROWSER)
151  console.info('Operation successful. IsDefaultApplicationSync ? ' + JSON.stringify(data));
152} catch(error) {
153  console.error('Operation failed. Cause: ' + JSON.stringify(error));
154};
155```
156