HarmonyOS APP版本名称和版本号的获取

文档上:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-inner-app-appversioninfo-V5

使用该方法获取版本号,但是实际代码中用的是getAppContext().applicationInfo同步获取对象,而且该对象没有versionCode, versionName参数。

HarmonyOS
2024-12-27 14:04:36
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Excelsior_abit

请参考:

import bundleManager from '@ohos.bundle.bundleManager';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
try {
  let data = bundleManager.getBundleInfoForSelfSync(bundleFlags);
  console.log('testTag', 'getBundleInfoForSelfSync successfully: %{public}s', JSON.stringify(data));
}
catch (err) {
  let message = (err as BusinessError).message;
  console.log( 'testTag', 'getBundleInfoForSelfSync failed: %{public}s', message);
} 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.

参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-inner-app-appversioninfo-V5

分享
微博
QQ
微信
回复
2024-12-27 15:21:52


相关问题
如何获取App版本号版本名等信息
5433浏览 • 1回复 待解决
如何获取APP版本名称
974浏览 • 1回复 待解决
HarmonyOS 如何获取当前APP版本号
1049浏览 • 1回复 待解决
HarmonyOS如何获取当前app版本号code
1696浏览 • 1回复 待解决
如何获取app/系统版本号
1217浏览 • 1回复 待解决
HarmonyOS 代码怎么获取APP版本号
825浏览 • 1回复 待解决
HarmonyOS 获取版本号
872浏览 • 1回复 待解决
stage模型怎么获取app版本号信息
2882浏览 • 1回复 待解决
HarmonyOS 版本号如何获取
909浏览 • 1回复 待解决
HarmonyOS 如何获取系统版本号
935浏览 • 1回复 待解决
如何获取当前手机系统版本号
1440浏览 • 1回复 待解决
HarmonyOS har包如何获取自身版本号
1191浏览 • 1回复 待解决