views:

216

answers:

4

I am developing a simple app for blacberry with eclipse. I have just set up a ListField with a call back and then my app don't want to stop running after I close it. One very annoying consequence is that I have to reboot the simulator each time I want to test my app.

Thank you for your help :D !

public class MyMainScreen extends MainScreen {
    private ListField lfMessage;   // UI list of messages
    // Constructor
    public MyMainScreen() {
     // set the title
     setTitle("My App");
     ListField lfMessage;
     lfMessage = new ListField();
     lfMessage.setEmptyString("Nothing to see here", DrawStyle.LEFT);
     lfMessage.setSize(5);
     lfMessage.setCallback(new MessageListCallBack());
     add(lfMessage);

    }

    // Menu item "Close"
    private MenuItem closeItem = new MenuItem("Close", 110, 10) {
     public void run() {
     lfMessage.setCallback(null);
     lfMessage = null;


     onClose();
     }
    };
+1  A: 

The default behavior of onClose() is to call onSavePrompt() if the screen is dirty, and call close() if successful. Calling close() directly will close the screen without the prompt, calling setDirty() will allow you to specify the state of the dirty flag, or as coldice mentioned calling System.exit(0) will terminate the program.

Richard
+2  A: 

Have you tried System.exit(0) ?

Max Gontar
A: 

I have tried both, but the app is still running!

A: 

try this just add this method to ur program and it will do the magic

public boolean onClose() { System.exit(0); return true; }

This will work for sure.