The user interface, like any other resource in the MIDP API, works within the context of the Application Management Software (AMS). When designing an application, the AMS behaves as follows:
The Display
class
represents the display manager of the AMS.
To obtain a Display
object, getDisplay()
method
is callable starting from MIDlet’s constructor until destroyApp()
has
returned.
Display
class has the methods setCurrent()
and getCurrent()
for
setting the current Displayable
and
retrieving the current Displayable
.
The Display
object remains the same
until destroyApp()
is called.
The Displayable
object set by setCurrent()
is
not changed by the AMS.
On S60, The call setCurrent(null)
sends
the MIDlet to the background. On Series 40, setCurrent(null)
does
nothing as the platform does not support Java application multitasking for
normal MIDlets.
On S60, a MIDlet in background is moved to foreground when
it calls setCurrent
with non-null displayable as a parameter.
On S60, user may move a MIDlet to background using Applications
key. When a MIDlet is moved to background it may not regain foreground with setCurrent
for
a fixed period of time (some seconds). This is done to prevent a MIDlet immediately
forcing itself to foreground when user is moving it to background.
User may force MIDlet to exit by pressing the Call Termination key.
The AMS also assumes that the application behaves as follows with respect to the MIDlet events:
startApp
- The application may call setCurrent()
for
the first screen. The AMS makes Displayable
visible when startApp()
returns.
Note that startApp()
can be called several times if pauseApp()
is
called in between. This means that in startApp()
, initialization
should not take place, and the application should not accidentally switch
to another screen with setCurrent()
.
pauseApp
- Since the purpose of the pauseApp
method
is unclear in the MIDP specification, by default Nokia S60 and Series 40 implementations
never call the pauseApp
method of a MIDlet. As a result
of this default behavior, the startApp
method won't be
called multiple times on Nokia implementations. However, since some other
than Nokia implementations call pauseApp
on various occasions
during the MIDlet lifecycle, it is recommended that MIDlets expect that the startApp
method
may be called multiple times.
Note: MIDP 3 specification will deprecate the pauseApp
method
because of the situation.
The default behavior can be changed by using Nokia proprietary JAD attributes Nokia-MIDlet-Background-Event
and Nokia-MIDlet-Flip-Close
.
It should be noted that the pauseApp
has nothing
to do with an application level pause feature, such as a pause mode of a game.
A game can implement a pause mode itself without the pauseApp
method
of MIDlet. For example, if a game should be automatically paused when it is
sent to background by the system or user it should implement this logic in
the hideNotify()
method of the Canvas
class.
destroyApp
- When destroyApp
is
called, the application releases all resources before exit. The destroyApp
method
is called when the user forces a MIDlet to exit by pressing the Call Termination
key.
For more information about AMS, see section MIDlet lifecycle.