mome
Class MoMIDlet

java.lang.Object
  extended by javax.microedition.midlet.MIDlet
      extended by mome.MoMIDlet
All Implemented Interfaces:
CommandListener, ItemCommandListener, ItemStateListener
Direct Known Subclasses:
MoXMIDlet

public abstract class MoMIDlet
extends MIDlet
implements CommandListener, ItemCommandListener, ItemStateListener

Class MoMIDlet is base abstract class that extends MIDlet. Applications that want to use only base functionality common for almost all MIDlets should extend this class. It implements CommandListener, ItemCommandListener, ItemStateListener, so it can be set as command listener on LCDUI components for commands processing. It introduces a property Display(accessed through getDisplay()) that holds a reference of Display instance associated with current MoMIDlet. It introduces a new callback method initApp(), that is called only the first time a MoMIDlet is started. Operations that must be done only the first time MIDlet enters the active state should be putted here. Display property is already set when this method executes. MIDletStateChangeException thrown from this method indicates transient failure; runtime exception - non transient failure. Any exception thrown will prevent setting initialized flag to true. This class also introduces method exit(), that just exits application.

Version:
1.0
Author:
Sergio Morozov

Constructor Summary
MoMIDlet()
           
 
Method Summary
 void exit()
          Exits application.
 Display getDisplay()
          Returns Display instance associated with the MIDlet.
protected  void initApp()
          Initialization method called from startApp().
protected  boolean isInitialized()
          Returns initialized flag.
protected  void startApp()
          Signals the MIDlet that it has entered the Active state.
 
Methods inherited from class javax.microedition.midlet.MIDlet
checkPermission, destroyApp, getAppProperty, notifyDestroyed, notifyPaused, pauseApp, platformRequest, resumeRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.microedition.lcdui.CommandListener
commandAction
 
Methods inherited from interface javax.microedition.lcdui.ItemCommandListener
commandAction
 
Methods inherited from interface javax.microedition.lcdui.ItemStateListener
itemStateChanged
 

Constructor Detail

MoMIDlet

public MoMIDlet()
Method Detail

initApp

protected void initApp()
                throws MIDletStateChangeException
Initialization method called from startApp(). Work that must be done only the first time MIDlet enters the active state should be putted here. As method is called from startApp(): MIDletStateChangeException thrown indicates transient failure; runtime exception - non transient failure. Any exception will prevent setting initialized flag to true. This method is called after Display instance was saved.

Throws:
MIDletStateChangeException - is thrown if the MIDlet cannot start now but might be able to start at a later time.
Since:
1.0

startApp

protected void startApp()
                 throws MIDletStateChangeException
Signals the MIDlet that it has entered the Active state.

Note To maintain the proper invocation of initApp() method subclasses overriding this method must call super method before other operations.

   protected void startApp() throws MIDletStateChangeException
   {
     super.startApp();
     
     ...
                         
   }
 

Specified by:
startApp in class MIDlet
Throws:
MIDletStateChangeException
Since:
1.0
See Also:
MIDlet.startApp()

isInitialized

protected boolean isInitialized()
Returns initialized flag.

Returns:
true if MIDlet was already initialized, false otherwise
Since:
1.0

getDisplay

public Display getDisplay()
Returns Display instance associated with the MIDlet.

Returns:
Display instance associated with the MIDlet.
Since:
1.0

exit

public void exit()
Exits application. Calls MIDlet.destroyApp( boolean) method with true parameter and notifies Application Management Software about exit (was any exception thrown or not).

Note Intended to be called from command processors.

Since:
1.0