• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Application Management
2
3
4> **NOTE**
5>
6> The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
7
8
9## Modules to Import
10
11
12```
13import pkg from '@system.package';
14```
15
16
17## package.hasInstalled
18
19hasInstalled(Object): void
20
21Checks whether an application exists, or whether a native application has been installed.
22
23**Required permissions**: ohos.permission.GET_BUNDLE_INFO
24
25**System capability**: SystemCapability.BundleManager.BundleFramework
26
27**Parameters**
28
29| Name | Type | Mandatory | Description |
30| -------- | -------- | -------- | -------- |
31| bundleName | string | Yes | Application bundle name. |
32| success | Function | No | Called when the check result is obtained. |
33| fail | Function | No | Called when the check result fails to be obtained. |
34| complete | Function | No | Called when the execution is complete. |
35
36The following value will be returned when the check result is obtained.
37
38| Name | Type | Description |
39| -------- | -------- | -------- |
40| result | boolean | The value **true** means that the application exists or the native application has been installed, and **false** means the opposite. |
41
42**Example**
43
44```
45export default {
46  hasInstalled() {
47    pkg.hasInstalled({
48      bundleName: 'com.example.bundlename',
49      success: function(data) {
50        console.log('package has installed: ' + data);
51      },
52      fail: function(data, code) {
53        console.log('query package fail, code: ' + code + ', data: ' + data);
54      },
55    });
56  },
57}
58```