Fields Summary |
---|
private List | mlistThe List of all the MIDlets. |
private Display | displayThe Display. |
private int | mcountNumber of midlets in minfo. |
private boolean | exitAfterLaunchshould this MIDlet exit after launching another MIDlet |
private MIDletInfo[] | minfoMIDlet information, class, name, icon; one per MIDlet. |
private Command | backCmdthe Command object to exit back to the MIDlet Suite Manager |
private Command | launchCmdthe Command object for "Launch". |
private int | selectedMidletIndex of the selected MIDlet, starts at -1 for non-selected. |
Methods Summary |
---|
private void | addMIDlet(MIDletInfo info)Add a MIDlet to the list.
if (mcount >= minfo.length) {
MIDletInfo[] n = new MIDletInfo[mcount+4];
System.arraycopy(minfo, 0, n, 0, mcount);
minfo = n;
}
minfo[mcount++] = info;
|
public void | commandAction(Command c, Displayable s)Respond to a command issued on any Screen.
The commands on list is Select and About.
Select triggers the creation of the MIDlet of the same name.
About puts up the copyright notice.
if ((s == mlist && c == List.SELECT_COMMAND) || (c == launchCmd)) {
synchronized (this) {
if (selectedMidlet != -1) {
// the previous selected MIDlet is being launched
return;
}
selectedMidlet = mlist.getSelectedIndex();
}
new Thread(this).start();
} else if (c == backCmd) {
destroyApp(false);
notifyDestroyed();
return;
}
|
public void | destroyApp(boolean unconditional)Destroy cleans up.
The only resource used is in the objects that will be
reclaimed by the garbage collector.
|
public void | pauseApp()Pause; there are no resources that need to be released.
|
private void | readMIDletInfo()Read in and create a MIDletInfor for each MIDlet-<n>
for (int n = 1; n < 100; n++) {
String nth = "MIDlet-"+ n;
String attr = getAppProperty(nth);
if (attr == null || attr.length() == 0)
break;
addMIDlet(new MIDletInfo(attr));
}
|
public void | run()Launch a the select MIDlet.
Scheduler scheduler = Scheduler.getScheduler();
String classname = minfo[selectedMidlet].classname;
try {
scheduler.register(MIDletState.createMIDlet(classname));
if (exitAfterLaunch) {
// exit
destroyApp(false);
notifyDestroyed();
return;
}
// Give the new MIDlet the screen by setting current to null
display.setCurrent(null);
// let another MIDlet be selected after MIDlet ends
selectedMidlet = -1;
return;
} catch (Exception ex) {
StringBuffer sb = new StringBuffer()
.append(minfo[selectedMidlet].name)
.append(", ")
.append(classname)
.append("\n")
.append(Resource.getString("Exception"))
.append(": ")
.append(ex.toString());
Alert a = new Alert(Resource.getString("Cannot start: "),
sb.toString(), null, null);
System.out.println("Unable to create MIDlet " + classname);
ex.printStackTrace();
display.setCurrent(a, mlist);
// let another MIDlet be selected after the alert
selectedMidlet = -1;
return;
}
|
private void | setupList()Read the set of MIDlet names, icons and classes
Fill in the list.
if (mlist == null) {
mlist = new List(Resource.getString("Select one to launch:"),
Choice.IMPLICIT);
// Add each midlet
for (int i = 0; i < mcount; i++) {
Image icon = null;
if (minfo[i].icon != null) {
try {
icon = Image.createImage(minfo[i].icon);
} catch (java.io.IOException noImage) {
// TBD: use a default ICON of the app has none.
}
}
mlist.append(" " + minfo[i].name, icon);
}
}
|
public void | startApp()Start puts up a List of the MIDlets found in the descriptor file.
setupList();
mlist.addCommand(launchCmd);
if (exitAfterLaunch) {
mlist.addCommand(backCmd);
}
mlist.setCommandListener(this); // Listen for the selection
display.setCurrent(mlist);
|