Alert

In MIDlets, Alerts are used to notify the user of errors, exceptions or otherwise important events by showing a popup window on top of the active MIDlet. Technically, Alert is a Screen that displays data either for a specified time period or as long until the user dismisses the prompt. The duration of the note is defined by getTimeout() method. If Alert.FOREVER is returned, the Alert is modal. Otherwise the Alert is timed.

Alert is displayed in a popup window on top of the previously displayed screen, which remains dimmed in the background. The popup window consists of several parts:

It is possible to map Commands to Alerts.

Figure 20: A timed Alert using the AlertType.INFO property

Source code for the example:

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class ExampleAlert extends MIDlet {
    Display display = Display.getDisplay(this);    
    
    public void startApp() {
        // Alert(title, text, icon, AlertType)        
        Alert alert = new Alert("Info", "This is an alert for informative purposes", null, AlertType.INFO);
        display.setCurrent(alert);
    }    
    public void pauseApp() {
    }    
    public void destroyApp(boolean unconditional) {
    }
}

For more information about S60-specific Alert features, see Alert implementation notes.