如何获取app配置的版本信息

如何获取app配置的版本信息

HarmonyOS
2024-01-30 19:13:25
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
xawind

三方应用:可以通过getBundleInfoForSelf获取自身的应用包信息,其中入参bundleFlags指定所返回的BundleInfo中所包含的信息。

import bundleManager from '@ohos.bundle.bundleManager'; 
import { BusinessError } from '@ohos.base'; 
import hilog from '@ohos.hilog'; 
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; 
try { 
    bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => { 
        hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data)); 
    }).catch((err: BusinessError) => { 
        hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message); 
    }); 
} catch (err) { 
    let message = (err as BusinessError).message; 
    hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message); 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.

参考链接

BundleInfo

分享
微博
QQ
微信
回复
2024-01-31 23:37:28
相关问题
arkTS获取app版本信息方法。
1808浏览 • 1回复 待解决
如何获取App版本号,版本名等信息
5485浏览 • 1回复 待解决
如何在Native侧获取APP版本信息
3028浏览 • 1回复 待解决
stage模型怎么获取app版本信息
2902浏览 • 1回复 待解决
HarmonyOS 如何获取版本信息
1099浏览 • 1回复 待解决
如何获取应用版本信息
2945浏览 • 1回复 待解决
app.getInfo获取应用配置信息为空。
1345浏览 • 1回复 待解决
如何获取APP版本名称?
987浏览 • 1回复 待解决
如何获取app/系统版本
1250浏览 • 1回复 待解决
HarmonyOS 如何获取当前APP版本号?
1085浏览 • 1回复 待解决
HarmonyOS 获取版本信息怎么使用呢
705浏览 • 1回复 待解决
如何在har中获取hap中配置信息
1111浏览 • 1回复 待解决
HarmonyOS APP版本名称和版本获取
1289浏览 • 1回复 待解决
如何获取应用信息以及彻底退出APP
1456浏览 • 1回复 待解决
如何获取应用信息以及彻底退出APP
1203浏览 • 1回复 待解决