public String getVersion() { PackageManager pm = getPackageManager(); try { PackageInfo packageInfo = pm.getPackageInfo(getPackageName(), 0); return packageInfo.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); // can't reach return ""; } }
PackageManager 包管理者 获取当前应用程序的版本号
时间: 2024-11-01 00:25:12