Displaying the correct MIDlet version in an About dialog
Article Metadata
This code snippet shows how to get the current version of the MIDlet for use in the app "About" dialog.
Novice Java ME developers often hard code the application version in the app About dialog. This is a mistake because it is easy for this value to get out of sync with the version in the JAD file (and thereby confuse end-users). To prevent such errors it is good practice to use the actual application version, taken from JAD file (or JAR file, if the JAD is absent).
Just use following code:
import javax.microedition.midlet.MIDlet;
public class MyMIDlet extends MIDlet {
public String getAppVersion() {
return this.getAppProperty("MIDlet-Version");
}
}


(no comments yet)