Skip to content

Instantly share code, notes, and snippets.

@reflog
Created June 16, 2010 17:38
Show Gist options
  • Save reflog/441007 to your computer and use it in GitHub Desktop.
Save reflog/441007 to your computer and use it in GitHub Desktop.
public static synchronized String getAppVersion() {
ApplicationDescriptor descriptor = ApplicationDescriptor.currentApplicationDescriptor();
String version = descriptor.getVersion(); //read from the alx files
if(version == null || version.trim().equals("")) { //read value from jad file
CodeModuleGroup[] allGroups = CodeModuleGroupManager.loadAll();
String moduleName = ApplicationDescriptor.currentApplicationDescriptor().getModuleName();
if (moduleName == null || allGroups == null) {
return "1.0 (sim)"; // be default, for simulator
}
for (int i = 0; i < allGroups.length; i++) {
if (allGroups[i] != null && allGroups[i].containsModule(moduleName)) {
version = allGroups[i].getProperty("MIDlet-Version");
if(version != null)
return version;
}
}
return "1.0 (dev)";
}
return version;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment