Note: Application Management Software (AMS) is known as Java Application Manager (JAM) on the Series 40 platform. For purposes of this library, the term AMS is used to refer to both, except where noted otherwise.
Figure: MIDlet sent to the background during a phone call
The AMS forms the core of the MIDlet lifecycle by providing the
context for all MIDlet activities. When a mobile device user selects
a MIDlet for execution, the AMS instantiates the MIDlet by calling
its startApp
method, which starts the lifecycle
of the MIDlet. The AMS maintains control over the MIDlet lifecycle
throughout its execution. The AMS does not make a distinction between
MIDlets and native applications, both of which it manages equally.
The AMS controls what is shown on the device display using the concepts of foreground and background. Only one application is active at a time in the foreground, with all other running applications relegated to background. On Symbian devices, there are no explicit restrictions to the number of MIDlets that can run at the same time, although the AMS can release resources by terminating inactive MIDlets or pausing active ones. On the Series 40 side, running MIDlets simultaneously is limited to those Series 40 devices that allow running MIDlets in the background. As a general rule, all Series 40 devices support running at least one MIDlet, that is, the MIDlet that is visible to the user on the device display.
How you control the foreground and background depends on the device platform:
On Symbian devices, to send a foreground MIDlet to the background,
call Display.setCurrent(null)
. The next application
brought the foreground is determined by the AMS. To activate a background
MIDlet and bring it to the foreground, call Display.setCurrent(Displayable)
. This causes a view activation in the native operating system, which
results in the MIDlet being brought to the foreground.
On Series 40 devices, to program a MIDlet to move between the foreground and the background, use the corresponding JAD attributes. The JAD attributes are only available to MIDlets that run in the manufacturer or operator domain. You cannot send MIDlets running in any other domain to the background.
The AMS also manages the MIDlet runtime states. The AMS can send
a MIDlet to the background or bring it to the foreground as a response
to user initiated actions, actions initiated by other applications,
or other runtime events. An example of such an event is an incoming
phone call, which results in the AMS sending the currently active
MIDlet to background. The AMS can also close a MIDlet at any time,
for example due to shortage of resources such as memory. The AMS calls
the MIDlet's destroyApp
method, forcing the application
to a graceful exit. If this fails, the AMS terminates the MIDlet forcefully.
For more information on MIDlet lifecycle, see the MIDlet specification.