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