Android 获取包名,版本信息及VersionName名称
Java代码
- <span style="font-size: 14px;">private String getAppInfo() {
- try {
- String pkName = this.getPackageName();
- String versionName = this.getPackageManager().getPackageInfo(
- pkName, 0).versionName;
- int versionCode = this.getPackageManager()
- .getPackageInfo(pkName, 0).versionCode;
- return pkName + " " + versionName + " " + versionCode;
- } catch (Exception e) {
- }
- return null;
- }</span>
时间: 2024-12-08 16:58:58