Skip to main content

How can exit CVM by a key press event when a MIDlet running?

1 reply [Last post]
Joined: 2010-06-08

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Hinkmond Wong

703416 wrote:
> How can I do? Thanks a lot!
> I use CDC_VM platform.

It depends on the MIDlet. Did you write the MIDlet? If you wrote the
MIDlet and you can edit the MIDlet source code, you can add new code to
override the keyPressed(int keyCode) method in your Canvas of your
MIDlet to call notifyDestroyed() to exit the MIDlet then use the AMS to
exit the CVM.

Ex. look at:

Use code that is something like this:

public void startApp () {
display = Display.getDisplay(this);

Canvas canvas = new Canvas() { // anonymous class

protected void keyPressed(int keyCode) {
if (keyCode == KEY_NUM7) {
System.out.println("keyPressed 7 to Exit");
} else {
System.out.println("keyPressed action " +getGameAction(keyCode));

Here's more info:

Most MIDlet writers put some type of Quit key for the user to press to
exit the MIDlet to go back to the AMS where you can quit and exit from
the VM that is running the AMS.


To unsubscribe, e-mail:
For additional commands, e-mail: