Java Reference
In-Depth Information
public void startApp() {
handler.handleSwitchToForeground();
} public void pauseApp() {
handler.handleSwitchToBackground();
}
Canvas notification methods also delegate the calls to the decoupled
location:
protected void hideNotify() {
handler.handleSwitchToBackground();
} protected void showNotify() {
handler.handleSwitchToForeground();
}
In Canvas-based MIDlets, for high-level UI screens, the MIDlet could
periodically check Displayable.isShown() on the current Dis-
playable object. For example, a separate thread could check every
once in a while (e.g., every second) if the current displayable object is
visible. If it is not, the application is moved to the background state and,
if it is, the application is moved to the foreground state.
Requesting a return to the foreground is possible but there are dif-
ferences in the implementation. On some platforms, calling MIDlet.
resumeRequest() is required, while on others calling Display.
setCurrent() with a displayable object is required. Applications can
switch themselves to the background on Nokia devices by calling Dis-
play.setCurrent(NULL) .
public void goToBackground() {
// will work on Nokia devices
Display.getDisplay(this).setCurrent(null);
}
public void returnToForeground() {
// duplicate action to ensure it is performed on various devices
this.resumeRequest();
Display.getDisplay(this).setCurrent(current);
}
4.6 Supporting Diverse Input Mechanisms
At the beginning of the chapter, we mentioned that some devices can be
used with one hand while others have a touch screen. For example, S60
5th Edition includes UI support for a touch screen as well as UIQ. If a
user buys a Nokia 5800 XpressMusic device with touch-screen support,
Search WWH ::




Custom Search