Skip to content

Instantly share code, notes, and snippets.

@erfanegtfi
Created April 13, 2018 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erfanegtfi/c5540a35abddceec10724fe4fba7ae95 to your computer and use it in GitHub Desktop.
Save erfanegtfi/c5540a35abddceec10724fe4fba7ae95 to your computer and use it in GitHub Desktop.
getAppVersionCode
public static Integer getAppVersionCode() {
try {
return Integer.valueOf(MyApplication.getContext().getPackageManager().getPackageInfo(MyApplication.getContext().getPackageName(), 0).versionCode);
} catch (Exception ex) {
ex.printStackTrace();
return Integer.valueOf(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment