Search code examples
blackberryjava-mestatus

Hide status message in Blackberry


A status message can be displayed in Blackberry using method show of class net.rim.device.api.ui.component.Status. Using this method you specify a certain amount of time that the message should be displayed but, is there any way to hide this status message BEFORE this time?

I am using this code for displaying status messages in my application:

public static void status(final String message, final int time) {
    UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Status.show(message, time); } });
}

EDIT: Solution that worked for me (thanks to Eugen Martynov solution)

public static void hideStatus() {
    UiApplication.getUiApplication().invokeLater(new Runnable() { 
        public void run() {
            Screen activeScreen = UiApplication.getUiApplication().getActiveScreen();
            if (activeScreen instanceof Status) {
                activeScreen.close();
            }
        }
    });
}

Solution

  • According to javadoc there no concrete method to close status.

    However you could try to ask UiApplication.getUiApplication().getActiveScreen() and try to call close() of it