1# Bundle Management Development 2 3## How do I determine whether an application is a system application? 4 5Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) 6 7**Solution** 8 9Use **bundleManager.getApplicationInfo** (available only for system applications) to obtain application information, and check the value of **systemApp** in the information. The application is a system application if the value is **true**. 10 11**Reference** 12 13[bundleManager](../reference/apis/js-apis-bundleManager.md) 14 15## How do I obtain the version code and version name of an application? 16 17Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) 18 19**Solution** 20 21Use **bundleManager.getBundleInfoForSelf\(\)** to obtain the bundle information, which contains the version code (specified by **BundleInfo.versionCode**) and version name (specified by **BundleInfo.versionName**) . 22 23**Example** 24 25``` 26import bundleManager from '@ohos.bundle.bundleManager'; 27import hilog from '@ohos.hilog'; 28let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; 29try { 30 bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => { 31 const versionCode = data.versionCode; 32 const versionName = data.versionName; 33 hilog.info(0x0000, 'testTag', `successfully. versionCode: ${versionCode}, versionName: ${versionName}`); 34 }).catch(err => { 35 hilog.error(0x0000, 'testTag', 'failed. Cause: %{public}s', err.message); 36 }); 37} catch (err) { 38 hilog.error(0x0000, 'testTag', 'failed: %{public}s', err.message); 39} 40``` 41 42**Reference** 43 44[getBundleInfoForSelf](../reference/apis/js-apis-bundleManager.md#bundlemanagergetbundleinfoforself) 45 46## How do I obtain the bundle name of the current application? 47 48Applicable to: OpenHarmony 3.2 Beta5 (API version 9) 49 50**Solution** 51 52Obtain the bundle name from **UIAbilityContext.abilityInfo.bundleName**. 53 54**Example** 55 56``` 57import common from '@ohos.app.ability.common'; 58const context = getContext(this) as common.UIAbilityContext 59console.log(`bundleName: ${context.abilityInfo.bundleName}`) 60``` 61 62**Reference** 63 64[UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontext) and [AbilityInfo](../reference/apis/js-apis-bundleManager-abilityInfo.md#abilityinfo) 65 66## How do I obtain the application version number, version name, and screen resolution? 67 68Applicable to: OpenHarmony 3.2 Beta5 69 70**Solution** 71 721. Obtain the bundle information from the **@ohos.bundle.bundleManager** module. 73 74 The bundle information contains the application version number and version name. 75 76 ``` 77 import bundleManager from '@ohos.bundle.bundleManager'; 78 ... 79 bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION).then((bundleInfo)=>{ 80 let versionName = bundleInfo.versionName; // Application version name. 81 let versionNo = bundleInfo.versionCode; // Application version number. 82 }).catch((error)=>{ 83 console.error("get bundleInfo failed,error is "+error) 84 }) 85 ``` 86 872. Obtain **screenDensity** from the **@ohos.app.ability.Configuration** module. **screenDensity** contains the screen resolution information. 88 89 ``` 90 import common from '@ohos.app.ability.common'; 91 ... 92 let context = getContext(this) as common.UIAbilityContext; 93 let screenDensity = context.config.screenDensity; 94 ``` 95 96 97## How do I obtain the source file path of the current application? 98 99Applicable to: OpenHarmony 3.2 Beta 5 (API version 9) 100 101**Solution** 102 103- Method 1: Use the application context to obtain the source file path. 104 105 ``` 106 this.uiAbilityContext.abilityInfo.applicationInfo.codePath 107 ``` 108 109- Method 2: Use **@ohos.bundle.bundleManager** to obtain the source file path. 110 111 1. Import the **@ohos.bundle.bundleManager** module and use **bundleManager.getBundleInfoForSelf\(\)** to obtain the bundle information. 112 2. Obtain the source file path from **bundleInfo.appInfo.codePath**. 113 114 ``` 115 import bundleManager from '@ohos.bundle.bundleManager'; 116 bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION).then((bundleInfo)=>{ 117 this.sourcePath = bundleInfo.appInfo.codePath; 118 }) 119 ``` 120 121 122## Can I obtain the HAP information of other applications from the current application? 123 124Applicable to: OpenHarmony 3.2 Beta (API version 9) 125 126According to the OpenHarmony security design specifications, the SDK does not provide APIs for third-party applications to obtain bundle information (including but not limited to the application name and version number) of other applications. 127