poiuytrez
poiuytrez

Reputation: 22546

Blackberry App still running

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 application.

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();
        }
    };

Upvotes: 0

Views: 457

Answers (3)

user188391
user188391

Reputation: 108

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.

Upvotes: 1

Richard
Richard

Reputation: 8920

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.

Upvotes: 2

Maksym Gontar
Maksym Gontar

Reputation: 22775

Have you tried System.exit(0) ?

Upvotes: 3

Related Questions