Thursday, September 30, 2010

sample J2ME code


For mobile device we are going to use MIDlet,like application for computer, applet for the web
  • All J2ME programs require import.javax.microedition package
  • MIDlet it is an abstract class.
  • Any J2ME class any inherit  it,can override the methods in it..
  • MIDlet not support user interaction, display message,multi-threading support
Sample code

e.g
// my   midlet.java file
import javax.microedition.midlet;//for MIDlet
import javax.microedition.lcdui; //for UI
public void startApp()   // to start the application
{
}
public void pauseApp() // to halt the application for a while
{
}
public void destroyApp() // to destroy application
{
}
private void exit()             //to close the application
{
System.gs()//garbage collection
destroyApp(false)//invoke destroy method
notifyDestroyed()// to notify application about destroyed thing
}




No comments:

Post a Comment