如何在库项目中从androidmanifest.xml获取版本?
因为在那里,我没有任何活动。
最佳答案
PackageManager m = getPackageManager();
String app_ver = "";
try {
app_ver = m.getPackageInfo(this.getPackageName(), 0).versionName;
}
catch (NameNotFoundException e) {
// Exception won't be thrown as the current package name is
// safe to exist on the system.
throw new AssertionError();
}