<span style= "FONT-SIZE:18PX;" >/** * Get local software version number */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", "version number of the Software". "+ localversion);} catch (Namenotfoundexception e) {e.printstacktrace ();} return localversion;} /** * Gets the local software version number name */public static String getlocalversionname (Context ctx) {String localversion = ""; try {packageinfo packa Geinfo = Ctx.getapplicationcontext (). Getpackagemanager (). Getpackageinfo (Ctx.getpackagename (), 0); localVersion = Packageinfo.versionname; LOGUTIL.D ("TAG", "version number of the Software". "+ localversion);} catch (Namenotfoundexception e) {e.printstacktrace ();} return localversion;} </span>
Android Gets the current software version number and version number name