For the Midlet Status, application management software is responsible for management. All you need to care about is how to deal with this AM.
PauseApp ()
DestroyApp ()
StartApp ()
Rewrite these three methods. AM will be called at the corresponding time.
While
NotifyDestroyed ()
NotifyPaused ()
ResumeRequest ()
It gives you the opportunity to notify AM about what to do.
The following is a simple example, which can be expanded and tested by yourself. One strange thing is that, in theory, when the Midlet is in Active state, if a call enters, AM will call pauseApp (). However, in the actual test, the method is not called by AM.
Package net. csdn. blog. vincint;
Import javax. microedition. midlet .*;
Import javax. microedition. lcdui .*;
/**
* This is a simple test to help me understanding the Midlet state
*
* <P> Title: Midlet Test </p>
* <P> Description: </p>
* <P> Copyright: Copyright (c) 2005 </p>
* <P> Company: A http://blog.csdn.net/Vincint </p>
* @ Author Vincint
* @ Version 1.0
*/
Public class MidletState
Extends MIDlet
Implements
CommandListener {
Protected Form form;
Protected Command exitCmd;
Protected Command debugCmd;
Protected Display display;
Protected String debug;
Public MidletState (){
AddDebugInfo ("In MidletState ()");
Display = Display. getDisplay (this );
Form = new Form ("Hello world .");
Form. append ("What a new world! ");
ExitCmd = new Command ("Exit", Command. EXIT, 1 );
DebugCmd = new Command ("Debug", Command. SCREEN, 2 );
Form. addCommand (exitCmd );
Form. addCommand (debugCmd );
Form. setCommandListener (this );
}
/**
* StartApp
*/
Protected void startApp (){
AddDebugInfo ("In startApp ()");
Display. setCurrent (form );
}
/**
* PauseApp
*/
Protected void pauseApp (){
AddDebugInfo ("In pauseApp ()");