Wednesday, February 17, 2010

Creating Your First Midlet

Hope you have your project created now, named FirstApp.
So now right click on project FirstApp and you will get a pop up menu in that menu,
New -> MIDlet
Now you will get a dialog box. There in midlet name type FirstMidlet and in package just type src for the time being. Click Finish.
Ok now you got your MIDlet which will look like this

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package src;

import javax.microedition.midlet.*;

/**
* @author Amila
*/
public class FirstMidlet extends MIDlet {
  public void startApp() {
  }

  public void pauseApp() {
  }

  public void destroyApp(boolean unconditional) {
  }
}

This is what we called midlet. The main class of the application. Just see that class has extended MIDlet class which is abstract. So three method are from MIDlet class
startApp() is your main method like in j2se. In j2me you don't have a main method instead of main method you have startApp as main method.
pauseApp() is the method which will get called from Application Management System(AMS) when application need to pause. eg. When mobile phone gets a call this function will be called.
destroyApp() this method is there to exit from the application. you can write your resource releasing kind of things in here.
So now you have created your first midlet and also have some knowledge about the midlets.

No comments:

Post a Comment