FileDocCategorySizeDatePackage
CldcMIDletStateListener.javaAPI DocphoneME MR2 API (J2ME)7935Wed May 02 18:00:06 BST 2007com.sun.midp.main

CldcMIDletStateListener

public class CldcMIDletStateListener extends Object implements MIDletStateListener
The class implements the MIDlet state listener for the CLDC VM.

Fields Summary
private com.sun.midp.security.SecurityToken
classSecurityToken
This class has a different security domain than the application.
protected com.sun.midp.lcdui.DisplayContainer
displayContainer
Stores array of active displays for a MIDlet suite isolate.
private MIDletControllerEventProducer
midletControllerEventProducer
Cached reference to the MIDletControllerEventProducer.
private boolean
vmInMidletStartMode
Indicates if the VM is in MIDlet start mode.
private boolean
previouslyActive
Indicate if a MIDlet has been active before.
Constructors Summary
CldcMIDletStateListener(com.sun.midp.security.SecurityToken token, com.sun.midp.lcdui.DisplayContainer theDisplayContainer, MIDletControllerEventProducer theMIDletControllerEventProducer)
Initializes this object.

param
token security token for this class.
param
theDisplayContainer display container
param
theMIDletControllerEventProducer event producer

        classSecurityToken = token;
        displayContainer = theDisplayContainer;
        midletControllerEventProducer = theMIDletControllerEventProducer;
    
Methods Summary
public voidmidletActivated(MIDletSuite suite, MIDlet midlet)
Called after a MIDlet is successfully activated. This is after the startApp method is called.

param
suite reference to the loaded suite
param
midlet reference to the MIDlet

        String className = midlet.getClass().getName();

        /*
         * JAMS UE feature: If a MIDlet has not set a current displayable
         * in its display by the time it has returned from startApp,
         * display the headless alert. The headless alert has been
         * set as the initial displayable but for the display but the
         * foreground has not been requested, to avoid displaying the
         * alert for MIDlet that do set a current displayable.
         */
        if (!previouslyActive) {
            previouslyActive = true;

            if (Display.getDisplay(midlet).getCurrent() == null) {
                displayContainer.requestForegroundForDisplay(className);
            }
        }

        midletControllerEventProducer.sendMIDletActiveNotifyEvent(
            suite.getID(), className);
    
public voidmidletCreated(MIDletSuite suite, java.lang.String className, int externalAppId)
Called after a MIDlet is successfully created.

param
suite reference to the loaded suite
param
className class name of the MIDlet
param
externalAppId ID of given by an external application manager

        
        midletControllerEventProducer.sendMIDletCreateNotifyEvent(
            suite.getID(), className, externalAppId,
                suite.getMIDletName(className));

        OtaNotifier.retryInstallNotification(classSecurityToken, suite);

        if (vmInMidletStartMode) {
            /*
             * Send a hint to VM about end of a MIDlet startup phase within
             * current isolate to allow VM to restore its internal parameters
             * changed for startup time for better performance
             */
            MIDletSuiteUtils.vmEndStartUp(
               classSecurityToken, MIDletSuiteUtils.getIsolateId());
            vmInMidletStartMode = false;
        }
    
public voidmidletDestroyed(MIDletSuite suite, java.lang.String className)
Called after a MIDlet is successfully destroyed.

param
suite reference to the loaded suite
param
className class name of the MIDlet

        displayContainer.removeDisplay(className);
        midletControllerEventProducer.sendMIDletDestroyNotifyEvent(
            suite.getID(), className);
    
public voidmidletPaused(MIDletSuite suite, java.lang.String className)
Called after a MIDlet is successfully paused.

param
suite reference to the loaded suite
param
className class name of the MIDlet

        midletControllerEventProducer.sendMIDletPauseNotifyEvent(
            suite.getID(), className);

        /*
         * IMPL_NOTE: it is now implied that MIDlet is always
         * requested to be paused together with all the
         * suspendable resources.
         *
         * This code is not suitable when mulitple MIDlet are running in this
         * isolate.
         */
        SuspendSystem.getInstance(classSecurityToken).suspend();
        midletControllerEventProducer.sendMIDletRsPauseNotifyEvent(
            suite.getID(), className);
    
public voidmidletPausedItself(MIDletSuite suite, java.lang.String className)
Called after a MIDlet pauses itself. In this case pauseApp has not been called.

param
suite reference to the loaded suite
param
className class name of the MIDlet

        midletControllerEventProducer.sendMIDletPauseNotifyEvent(
            suite.getID(), className);
    
public voidmidletPreStart(MIDletSuite suite, java.lang.String className)
Called before a MIDlet is created.

param
suite reference to the loaded suite
param
className class name of the MIDlet to be created

        /*
         * Send a hint to VM about begining of a MIDlet startup phase within
         * current isolate to allow VM to adjust internal parameters for
         * better performance
         */
        MIDletSuiteUtils.vmBeginStartUp(
            classSecurityToken, MIDletSuiteUtils.getIsolateId());
        vmInMidletStartMode = true;

        // Do ContentHandler initialization for this MIDlet
        CHManager.getManager(classSecurityToken).
            midletInit(suite.getID(), className);
    
public voidpreActivated(MIDletSuite suite, java.lang.String className)
Called before a MIDlet is activated.

param
suite reference to the loaded suite
param
className class name of the MIDlet

        SuspendSystem.getInstance(classSecurityToken).resume();
    
public voidresumeRequest(MIDletSuite suite, java.lang.String className)
Called when a MIDlet calls MIDlet resume request.

param
suite reference to the loaded suite
param
className class name of the MIDlet

        midletControllerEventProducer.sendMIDletResumeRequest(
            suite.getID(), className);