- startApp()
- pauseApp()destroyApp()
- distroyApp()
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class MidletLifecycle extends MIDlet{
private Display display;//Initializing the Display.ONly one Display for one application.
private Form form;
//Initializing the Form.Form is a sub-class of Display
public MidletLifecycle(){
System.out.println("MidletLifecycle constructor");
}
//As we know the main method of a mobile app
public void startApp(){
form = new Form("Midlet Lifecycle");
display = Display.getDisplay(this);
String msg = "This is the Lifecycle of Midlet!";
form.append(msg);//adding the message to form
display.setCurrent(form);//adding the form to display
}
public void pauseApp(){
System.out.println("You are in pauseApp()...");
}
public void destroyApp(boolean destroy){
System.out.println("You are in destroyApp()...");
notifyDestroyed();
}
}
OutOut
MidletLifecycle constructor //appears when the app is running
You are in destroyApp()... //appears after the app is closed
javacall_lifecycle_state_changed() lifecycle: event is JAVACALL_LIFECYCLE_MIDLET_SHUTDOWNstatus is JAVACALL_OK
credit to : roseindia.net
No comments:
Post a Comment