<span style="font-size:18px;">/** * 获取本地软件版本号 */ public static int getLocalVersion(Context ctx) { int localVersion = 0; try { PackageInfo packageInfo = ctx.getApplicationContext() .getPackageManager() .getPackageInfo(ctx.getPackageName(), 0); localVersion = packageInfo.versionCode; LogUtil.d("TAG", "本软件的版本号。。" + localVersion); } catch (NameNotFoundException e) { e.printStackTrace(); } return localVersion; } /** * 获取本地软件版本号名称 */ public static String getLocalVersionName(Context ctx) { String localVersion = ""; try { PackageInfo packageInfo = ctx.getApplicationContext() .getPackageManager() .getPackageInfo(ctx.getPackageName(), 0); localVersion = packageInfo.versionName; LogUtil.d("TAG", "本软件的版本号。。" + localVersion); } catch (NameNotFoundException e) { e.printStackTrace(); } return localVersion; }</span>