• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
08 Midlet Basic
 

08 Midlet Basic

on

  • 1,255 views

 

Statistics

Views

Total Views
1,255
Views on SlideShare
1,254
Embed Views
1

Actions

Likes
0
Downloads
34
Comments
0

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    08 Midlet Basic 08 Midlet Basic Presentation Transcript

    • 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 startthe MIDlet.
    • pauseApp()protected void pauseApp() {}Called by application manager beforepausing the MIDlet.
    • destroyApp() protected void destroyApp(boolean arg0) throws MIDletStateChangeException {}Called by application manager to prior toshutdown.
    • 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.