Easy (I do it all the time). Create two (almost identical) commands
static final Command pauseCommand = new Command("Pause", Command.ITEM, 1);
static final Command resumeCommand = new Command("Resume", Command.ITEM, 1);
In your startup code, add only the pause command to your displayable (canvas, form or whatever).
In your
commandAction
routine, have something like this:
public void commandAction(Command cmd, Displayable disp) {
if (cmd.equals(pauseCommand)) {
disp.removeCommand(pauseCommand);
disp.addCommand(resumeCommand);
} else if (cmd.equals(resumeCommand)) {
disp.removeCommand(resumeCommand);
disp.addCommand(pauseCommand);
}
}
Note that if you are really pausing the midlet, a resume command inside it won't be very useful!
Peter
[edit] fixed typo in cut'n'pasted code. [/edit]