Sunday, February 23, 2014

Andrews how to get the current version of the software information


doing software updates when experiencing a problem that can not always get the current version. The relevant code below
private int newVerCode = 0;
private String newVerName = "";

if (getServerVerCode ()) {
int vercode = Config.getVerCode (this) ;/ / this, then you do not have to perform the same
if (newVerCode> vercode) {
getServerVerCode ();
doNewVersionUpdate ();
}
}

/ / This is the way to get the current version
public static int getVerCode (Context context) {
int verCode = -1;
try {
verCode = context.getPackageManager (). getPackageInfo (
"Com.gdpost.activity.updateactivity", 0) versionCode;.
} Catch (NameNotFoundException e) {
Log.e (TAG, e.getMessage ());
}
return verCode;
}

public static String getVerName (Context context) {
String verName = "";
try {
verName = context.getPackageManager (). getPackageInfo (
"Com.gdpost.activity.updateactivity", 0) versionName;.
} Catch (NameNotFoundException e) {

Log.e (TAG, e.getMessage ());
}
return verName;
}
seek expert to explain why I get less than the current version number <-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
 PackageInfo pkg = context.getPackageManager () getPackageInfo (context.getPackageName (), 0);. 
APP_VERSION = pkg.versionName;
APP_VERSION_CODE = pkg.versionCode;

If the error message Error break out
Reply:
A building on it, in the configuration file write android: versionCode = "10001"
Reply:
cited a floor youngc527 reply:
 PackageInfo pkg = context.getPackageManager () getPackageInfo (context.getPackageName (. ), 0); 
APP_VERSION = pkg.versionName;
APP_VERSION_CODE = pkg.versionCode;

If the error message Error playing out
Thank you! I myself have been resolved

No comments:

Post a Comment