MIDletEventListenerpublic class MIDletEventListener extends Object implements com.sun.midp.events.EventListenerListener for MIDlet related events (state changes, etc). |
Fields Summary |
---|
private com.sun.midp.events.EventQueue | eventQueueCached reference to the MIDP event queue. | private MIDletStateHandler | midletStateHandlerThe controller of MIDlets. | private static com.sun.midp.security.SecurityToken | classSecurityTokenThis class has a different security domain than the application. |
Constructors Summary |
---|
public MIDletEventListener(com.sun.midp.security.SecurityToken token, MIDletStateHandler theMIDletStateHandler, com.sun.midp.events.EventQueue theEventQueue)The constructor for the default event handler for LCDUI.
token.checkIfPermissionAllowed(Permissions.AMS);
classSecurityToken = token;
midletStateHandler = theMIDletStateHandler;
eventQueue = theEventQueue;
/*
* All events handled by this object are of NativeEventClass
* and are instance specific events assosiated with some display Id.
* So this listener is able to find an appropriate DisplayEventConsumer
* associated with the displayId field of NativeEvent and
* to call methods of found consumer.
*/
eventQueue.registerEventListener(EventTypes.ACTIVATE_MIDLET_EVENT,
this);
eventQueue.registerEventListener(EventTypes.PAUSE_MIDLET_EVENT, this);
eventQueue.registerEventListener(EventTypes.DESTROY_MIDLET_EVENT,
this);
|
Methods Summary |
---|
public boolean | preprocess(com.sun.midp.events.Event event, com.sun.midp.events.Event waitingEvent)Preprocess an event that is being posted to the event queue.
return true;
| public void | process(com.sun.midp.events.Event event)Process an event.
NativeEvent nativeEvent = (NativeEvent)event;
MIDletEventConsumer midletEventConsumer =
midletStateHandler.getMIDletEventConsumer(classSecurityToken,
nativeEvent.stringParam1);
if (midletEventConsumer != null) {
switch (event.getType()) {
case EventTypes.ACTIVATE_MIDLET_EVENT:
midletEventConsumer.handleMIDletActivateEvent();
return;
case EventTypes.PAUSE_MIDLET_EVENT:
midletEventConsumer.handleMIDletPauseEvent();
return;
case EventTypes.DESTROY_MIDLET_EVENT:
midletEventConsumer.handleMIDletDestroyEvent();
return;
default:
if (Logging.REPORT_LEVEL <= Logging.WARNING) {
Logging.report(Logging.WARNING, LogChannels.LC_CORE,
"unknown system event (" +
event.getType() + ")");
}
}
}
|
|