<span style= "FONT-SIZE:18PX;" >/** * Get local software version */public static int getlocalversion (Context ctx) {int localversion = 0;try {PackageInfo PackageInfo = C Tx.getapplicationcontext (). Getpackagemanager (). Getpackageinfo (Ctx.getpackagename (), 0); localversion = Packageinfo.versioncode; LOGUTIL.D ("TAG", "version of this software: "+ localversion);} catch (Namenotfoundexception e) {e.printstacktrace ();} return localversion;} /** * Get local software version name */public static String getlocalversionname (Context ctx) {String localversion = ""; try {packageinfo packag Einfo = Ctx.getapplicationcontext (). Getpackagemanager (). Getpackageinfo (Ctx.getpackagename (), 0); localVersion = Packageinfo.versionname; LOGUTIL.D ("TAG", "version of this software: "+ localversion);} catch (Namenotfoundexception e) {e.printstacktrace ();} return localversion;} </span>
Android Gets the current software version number and version name