public static int getAppVersion ( @ NonNull final Context context ) { try { final PackageInfo packageInfo = context . getPackageManager ( ) . getPackageInfo ( context . getPackageName ( ) , 0 ) ; return packageInfo . versionCode ; } catch ( PackageManager . NameNotFoundException ignore ) { // ignore } return Integer . MIN_VALUE ; }
Returns the version code of the application .