SlideShare a Scribd company logo
MIDlet Basic


       Cornelius Koo – 2005
        cornelius.mellino@gmail.com
MIDlet
• MIDlet is an application that is built upon
  the MIDlet class.
• MIDlet can communicate with Application
  Manager in two-way direction.
     Example: Application Manager can pause a MIDlet, while MIDlet
     can make a request to be paused by Application Manager.
MIDlet Lifecycle
Pause
• Paused: A MIDlet is placed in the paused
  state after the constructor has been called,
  but prior to being started by the application
  manager. Once the MIDlet had been
  started, it may alternate between the
  Paused and Active states many times
  during its lifecycle.
Active
• Active: The MIDlet is running.
Destroyed
• Destroyed: The MIDlet has released any
  resources it required, and has been shut
  down by the application manager.
import javax.microedition.midlet.MIDlet;

public class HelloWorld extends MIDlet {

    public HelloWorld() {}

    protected void startApp() throws
       MIDletStateChangeException {}

    protected void pauseApp() {}

    protected void destroyApp(boolean arg0) throws
       MIDletStateChangeException {}
}
startApp()
protected void startApp() throws
    MIDletStateChangeException {}

Called by application manager to start
the MIDlet.
pauseApp()
protected void pauseApp()
 {}

Called by application manager before
pausing the MIDlet.
destroyApp()
 protected void
 destroyApp(boolean arg0) throws
    MIDletStateChangeException {}

Called by application manager to prior to
shutdown.
javax.microedition.midlet.MIDlet
Warning !
• Don’t leave the code that persist through
  MIDlet lifecycle or code that runs just once
  time in the startApp() method because it’ll
  be invoked by application manager many
  times.
Warning !
• When paused or destroyed, MIDlet should
  release as many resources as possible.
notifyDestroyed()
• MIDlet signals application manager that it’ll
  be shutted down.
• Sequence :
  - User request to exit
  - destroyApp() – releasing resources
  - notifyDestroyed() – tell app. manager it’s
    safe to shutdown the MIDlet.
getAppProperty()
• When needed to query MIDlet attributes,
  use getAppProperty().
Monitoring MIDlet
   Transition
import javax.microedition.midlet.MIDlet;

public class StateTransition extends MIDlet {

     public StateTransition() {
        System.out.println(“constructor”);
    }
     protected void startApp() throws
        MIDletStateChangeException {
        System.out.println(“start”);
    }
     protected void pauseApp() {
        System.out.println(“pause”);
    }
     protected void destroyApp(boolean arg0) throws
        MIDletStateChangeException {
        System.out.println(“destroy”);
    }
}
MIDletStateChangeException


       Thrown when error occur on state changes
Example MIDlet : TestException.java
Reference
• Core J2ME Technology and MIDP. John
  W. Muchow. Prentice Hall PTR, 2002.
• Enterprise J2ME: Developing Mobile
  Java Applications. Michael Juntao Yuan.
  Prentice Hall PTR, 2003.
• J2ME in A Nutshell. Kim Topley. Oreilly,
  2002.

More Related Content

PPT
Introduction to j2me
PPT
PPT
Mobile Application Development MAD J2ME
PPTX
Introduction To J2ME(FT - Prasanjit Dey)
PPTX
Introduction to Mobile programming(J2ME)
PPTX
J2ME mobile app development
PPT
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
PPS
J2ME Unit_01
Introduction to j2me
Mobile Application Development MAD J2ME
Introduction To J2ME(FT - Prasanjit Dey)
Introduction to Mobile programming(J2ME)
J2ME mobile app development
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
J2ME Unit_01

What's hot (19)

PDF
Java2 MicroEdition-J2ME
PPTX
Blackberry Development Environment
PDF
Ajava final(sachin sir9822506209)_vision_academy_21
DOCX
Mobile application development
PPT
Introduction to Mobile Application Development
PDF
Javame sdk-datasheet-167819
PPTX
Chapter 11:Understanding Client-Side Technologies
PPTX
Chapter 10:Understanding Java Related Platforms and Integration Technologies
PPT
Java J2EE
PPTX
Chapter2 j2ee
PDF
A dynamic application using jboss
PDF
06 Eclipse ME
PDF
Introduction to Java EE (J2EE)
PDF
A Project Report on Insurance System with Tracking Manager
PDF
Java remote control for laboratory monitoring
PPTX
J2ee seminar
PPTX
J2 ee architecture
PPT
PDF
Ah java-ppt1
Java2 MicroEdition-J2ME
Blackberry Development Environment
Ajava final(sachin sir9822506209)_vision_academy_21
Mobile application development
Introduction to Mobile Application Development
Javame sdk-datasheet-167819
Chapter 11:Understanding Client-Side Technologies
Chapter 10:Understanding Java Related Platforms and Integration Technologies
Java J2EE
Chapter2 j2ee
A dynamic application using jboss
06 Eclipse ME
Introduction to Java EE (J2EE)
A Project Report on Insurance System with Tracking Manager
Java remote control for laboratory monitoring
J2ee seminar
J2 ee architecture
Ah java-ppt1
Ad

Similar to 08 Midlet Basic (20)

PPT
Mobile Application Development MAD J2ME UNIT 2
PPT
Session 3 J2ME Mobile Information Device Profile(MIDP) API
PPTX
Lab 1 new
PDF
Developing midlets
PDF
J2me Crash Course
PDF
Intro to MIDP Development
PPT
Mobile Application Development JEDI Chapter 2
PPT
Session2-J2ME development-environment
PDF
J2ME GUI Programming
PPT
Scmad Chapter03
PPT
CIS 642 - Mobile Information Device profie
PPTX
Nokia Asha App Development - Part 1
PPTX
Game Development for Nokia Asha Devices with Java ME #1
PPT
Introduction to JAVA ME Mobile Application.ppt
PPT
A Taste of Java ME
PDF
Mobile Development. A primer.
PDF
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
PDF
09 Display
PPT
Java ME CLDC MIDP
DOCX
Contoh bahan latihan programan mobile java
Mobile Application Development MAD J2ME UNIT 2
Session 3 J2ME Mobile Information Device Profile(MIDP) API
Lab 1 new
Developing midlets
J2me Crash Course
Intro to MIDP Development
Mobile Application Development JEDI Chapter 2
Session2-J2ME development-environment
J2ME GUI Programming
Scmad Chapter03
CIS 642 - Mobile Information Device profie
Nokia Asha App Development - Part 1
Game Development for Nokia Asha Devices with Java ME #1
Introduction to JAVA ME Mobile Application.ppt
A Taste of Java ME
Mobile Development. A primer.
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
09 Display
Java ME CLDC MIDP
Contoh bahan latihan programan mobile java
Ad

More from corneliuskoo (13)

PDF
Basic JSTL
PDF
Expression Language in JSP
PDF
PDF
Html Hands On
PDF
13 Low Level UI Event Handling
PDF
12 High Level UI Event Handling
PDF
07 Midlet On The Web
PDF
05 J2ME Wtk Command Line
PDF
04 J2ME Wireless Tool Kit
PDF
03 midp
PDF
02a cldc property support
PDF
02 cldc
PDF
01 java 2 micro edition
Basic JSTL
Expression Language in JSP
Html Hands On
13 Low Level UI Event Handling
12 High Level UI Event Handling
07 Midlet On The Web
05 J2ME Wtk Command Line
04 J2ME Wireless Tool Kit
03 midp
02a cldc property support
02 cldc
01 java 2 micro edition

08 Midlet Basic

  • 1. MIDlet Basic Cornelius Koo – 2005 cornelius.mellino@gmail.com
  • 2. MIDlet • MIDlet is an application that is built upon the MIDlet class. • MIDlet can communicate with Application Manager in two-way direction. Example: Application Manager can pause a MIDlet, while MIDlet can make a request to be paused by Application Manager.
  • 4. Pause • Paused: A MIDlet is placed in the paused state after the constructor has been called, but prior to being started by the application manager. Once the MIDlet had been started, it may alternate between the Paused and Active states many times during its lifecycle.
  • 5. Active • Active: The MIDlet is running.
  • 6. Destroyed • Destroyed: The MIDlet has released any resources it required, and has been shut down by the application manager.
  • 7. import javax.microedition.midlet.MIDlet; public class HelloWorld extends MIDlet { public HelloWorld() {} protected void startApp() throws MIDletStateChangeException {} protected void pauseApp() {} protected void destroyApp(boolean arg0) throws MIDletStateChangeException {} }
  • 8. startApp() protected void startApp() throws MIDletStateChangeException {} Called by application manager to start the MIDlet.
  • 9. pauseApp() protected void pauseApp() {} Called by application manager before pausing the MIDlet.
  • 10. destroyApp() protected void destroyApp(boolean arg0) throws MIDletStateChangeException {} Called by application manager to prior to shutdown.
  • 12. Warning ! • Don’t leave the code that persist through MIDlet lifecycle or code that runs just once time in the startApp() method because it’ll be invoked by application manager many times.
  • 13. Warning ! • When paused or destroyed, MIDlet should release as many resources as possible.
  • 14. notifyDestroyed() • MIDlet signals application manager that it’ll be shutted down. • Sequence : - User request to exit - destroyApp() – releasing resources - notifyDestroyed() – tell app. manager it’s safe to shutdown the MIDlet.
  • 15. getAppProperty() • When needed to query MIDlet attributes, use getAppProperty().
  • 16. Monitoring MIDlet Transition
  • 17. import javax.microedition.midlet.MIDlet; public class StateTransition extends MIDlet { public StateTransition() { System.out.println(“constructor”); } protected void startApp() throws MIDletStateChangeException { System.out.println(“start”); } protected void pauseApp() { System.out.println(“pause”); } protected void destroyApp(boolean arg0) throws MIDletStateChangeException { System.out.println(“destroy”); } }
  • 18. MIDletStateChangeException Thrown when error occur on state changes
  • 19. Example MIDlet : TestException.java
  • 20. Reference • Core J2ME Technology and MIDP. John W. Muchow. Prentice Hall PTR, 2002. • Enterprise J2ME: Developing Mobile Java Applications. Michael Juntao Yuan. Prentice Hall PTR, 2003. • J2ME in A Nutshell. Kim Topley. Oreilly, 2002.