Home J2me Midlet Lifecycle



Midlet Lifecycle
Posted on: October 3, 2008 at 12:00 AM
By default Midlet is in the paused states. when the application is executed by default startApp() method will call and when close the application the destroyApp() method will be called.

Midlet Lifecycle

     

A MIDlet lifecycle have following steps...

  • startApp()
  • pauseApp()
  • destroyApp()

By default MIDlet is in the paused states. when the application is executed by default startApp() method will call and when close the application the destroyApp() method will be called. But when your constructor is not null type then it will be executed firstly. The source code of life cycle execution is as follows:

 

 

 

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;

public class MidletLifecycle extends MIDlet{
  private Form form;
  
  private Display display;

  public MidletLifecycle(){
  System.out.println("MidletLifecycle constructure");
  }

  public void startApp(){
  form = new Form("Midlet Lifecycle");
  display = Display.getDisplay(this);
  String msg = "This is the Lifecycle of Midlet!";
  form.append(msg);
  display.setCurrent(form);
  }

  public void pauseApp(){
  System.out.println("You are in pauseApp()...");
  }

  public void destroyApp(boolean destroy){
  System.out.println("You are in destroyApp()...");
  notifyDestroyed();
  }
}

 

Fig: MIDlet Lifecycle

Output:

Download Source Code

Related Tags for Midlet Lifecycle:
cstlapplicationconstructornulliostructmethodsedtypeconstdefaultexecstateidexetarappclosestartcallexecutetoidlmidletidleeilitdespausenotmidlliuseulpefirstartfaultinnocalstamtroscaosletstatesclestapallmeppcatcuttorwhensxectorstaratisirllandarstatclosconsstrrtssthstatiapctoefaulticaicaplmindono


More Tutorials from this section

Ask Questions?    Discuss: Midlet Lifecycle   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.