Java Reference
In-Depth Information
The advantages and disadvantages are the same as with graceful
functional degradation - the module is always in the JAR, which means
the JAR is bigger but there is only one JAR to maintain.
4.5 Handling Transitions Between Foreground
and Background
Since Symbian OS is a multitasking operating system, the Application
Management Software (AMS) can move your MIDlet to the background
to allow another application to execute concurrently. After a while, your
MIDlet may then be sent back to the foreground.
In S60 5th Edition and 3rd Edition FP2 devices, the MIDlet lifecy-
cle methods are not called by default. To request the AMS to invoke
MIDlet.startApp() and MIDlet.pauseApp() , you need to add
the Nokia-MIDlet-Background-Event 1 proprietary JAD attribute
with the value "pause" . By default, the attribute value is "run" and
pauseApp() and startApp() are not called by the AMS. An alterna-
tive way to deal with the MIDlet lifecycle methods not being invoked is
to override the Canvas.hideNotify() method, which is called when
the MIDlet is sent to the background, and the Canvas.showNotify()
method, which is called when it is moved to the foreground.
What you should ensure is the handling of state switching in both cases
so that your application behaves similarly on Symbian smartphones from
different vendors. A possible solution would be to decouple the handling
of state switching from the specific notification events to handle them in
a separate location.
public class StateHandler {
public synchronized void handleSwitchToBackground() {
background = true;
// TODO: handle switching to background
} public synchronized void handleSwitchToForeground() {
background = false;
// TODO: handle switching to foreground
}
}
Then, MIDlet lifecycle methods delegate the calls to the decoupled
location:
1 www.forum.nokia.com/document/JavaMEDevelopers Library
Search WWH ::




Custom Search