在开发的过程中,需要获得版本号
private PackageInfo getVersion() {
PackageManager packageManager = MyApplication.getInstance().getPackageManager();
PackageInfo packageInfo = null;
try {
packageInfo = packageManager.getPackageInfo(MyApplication.getInstance().getPackageName(), 0);
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return packageInfo;
} private String getVersionName() {
return getVersion().versionName;
} private String getVersionCode() {
return String.valueOf(getVersion().versionCode);
}
==完