SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
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.

Mais conteúdo relacionado

Mais procurados

Java2 MicroEdition-J2ME
Java2 MicroEdition-J2MEJava2 MicroEdition-J2ME
Java2 MicroEdition-J2MERohan Chandane
 
Blackberry Development Environment
Blackberry Development EnvironmentBlackberry Development Environment
Blackberry Development EnvironmentPredhin Sapru
 
Ajava final(sachin sir9822506209)_vision_academy_21
Ajava final(sachin sir9822506209)_vision_academy_21Ajava final(sachin sir9822506209)_vision_academy_21
Ajava final(sachin sir9822506209)_vision_academy_21SachinZurange
 
Introduction to Mobile Application Development
Introduction to Mobile Application DevelopmentIntroduction to Mobile Application Development
Introduction to Mobile Application DevelopmentSenthil Kanth
 
Javame sdk-datasheet-167819
Javame sdk-datasheet-167819Javame sdk-datasheet-167819
Javame sdk-datasheet-167819Oscar Eduardo
 
Chapter 11:Understanding Client-Side Technologies
Chapter 11:Understanding Client-Side TechnologiesChapter 11:Understanding Client-Side Technologies
Chapter 11:Understanding Client-Side TechnologiesIt Academy
 
Chapter 10:Understanding Java Related Platforms and Integration Technologies
Chapter 10:Understanding Java Related Platforms and Integration TechnologiesChapter 10:Understanding Java Related Platforms and Integration Technologies
Chapter 10:Understanding Java Related Platforms and Integration TechnologiesIt Academy
 
A dynamic application using jboss
A dynamic application using jbossA dynamic application using jboss
A dynamic application using jbossijcax
 
Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)Atit Patumvan
 
A Project Report on Insurance System with Tracking Manager
 A Project Report on Insurance System with Tracking Manager  A Project Report on Insurance System with Tracking Manager
A Project Report on Insurance System with Tracking Manager Sachin Kariyattin
 
Java remote control for laboratory monitoring
Java remote control for laboratory monitoringJava remote control for laboratory monitoring
Java remote control for laboratory monitoringIAEME Publication
 
J2 ee architecture
J2 ee architectureJ2 ee architecture
J2 ee architectureKrishna Mer
 

Mais procurados (19)

Java2 MicroEdition-J2ME
Java2 MicroEdition-J2MEJava2 MicroEdition-J2ME
Java2 MicroEdition-J2ME
 
Blackberry Development Environment
Blackberry Development EnvironmentBlackberry Development Environment
Blackberry Development Environment
 
Ajava final(sachin sir9822506209)_vision_academy_21
Ajava final(sachin sir9822506209)_vision_academy_21Ajava final(sachin sir9822506209)_vision_academy_21
Ajava final(sachin sir9822506209)_vision_academy_21
 
Mobile application development
Mobile application developmentMobile application development
Mobile application development
 
Introduction to Mobile Application Development
Introduction to Mobile Application DevelopmentIntroduction to Mobile Application Development
Introduction to Mobile Application Development
 
Javame sdk-datasheet-167819
Javame sdk-datasheet-167819Javame sdk-datasheet-167819
Javame sdk-datasheet-167819
 
Chapter 11:Understanding Client-Side Technologies
Chapter 11:Understanding Client-Side TechnologiesChapter 11:Understanding Client-Side Technologies
Chapter 11:Understanding Client-Side Technologies
 
Chapter 10:Understanding Java Related Platforms and Integration Technologies
Chapter 10:Understanding Java Related Platforms and Integration TechnologiesChapter 10:Understanding Java Related Platforms and Integration Technologies
Chapter 10:Understanding Java Related Platforms and Integration Technologies
 
Java J2EE
Java J2EEJava J2EE
Java J2EE
 
Chapter2 j2ee
Chapter2 j2eeChapter2 j2ee
Chapter2 j2ee
 
A dynamic application using jboss
A dynamic application using jbossA dynamic application using jboss
A dynamic application using jboss
 
06 Eclipse ME
06 Eclipse ME06 Eclipse ME
06 Eclipse ME
 
Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)
 
A Project Report on Insurance System with Tracking Manager
 A Project Report on Insurance System with Tracking Manager  A Project Report on Insurance System with Tracking Manager
A Project Report on Insurance System with Tracking Manager
 
Java remote control for laboratory monitoring
Java remote control for laboratory monitoringJava remote control for laboratory monitoring
Java remote control for laboratory monitoring
 
J2ee seminar
J2ee seminarJ2ee seminar
J2ee seminar
 
J2 ee architecture
J2 ee architectureJ2 ee architecture
J2 ee architecture
 
J2ee
J2eeJ2ee
J2ee
 
Ah java-ppt1
Ah java-ppt1Ah java-ppt1
Ah java-ppt1
 

Semelhante a MIDlet Basics - The Lifecycle of a MIDlet Application

Session 3 J2ME Mobile Information Device Profile(MIDP) API
Session 3 J2ME Mobile Information Device Profile(MIDP)  APISession 3 J2ME Mobile Information Device Profile(MIDP)  API
Session 3 J2ME Mobile Information Device Profile(MIDP) APImuthusvm
 
Mobile Application Development MAD J2ME UNIT 2
Mobile Application Development  MAD J2ME UNIT 2Mobile Application Development  MAD J2ME UNIT 2
Mobile Application Development MAD J2ME UNIT 2Pallepati Vasavi
 
J2me Crash Course
J2me Crash CourseJ2me Crash Course
J2me Crash Courseguest860a03
 
RIBs - Fragments which work
RIBs - Fragments which workRIBs - Fragments which work
RIBs - Fragments which workDmitry Zaytsev
 
Spring Boot and Microservices
Spring Boot and MicroservicesSpring Boot and Microservices
Spring Boot and Microservicesseges
 
Improving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesImproving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesHassan Abid
 
The new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfileThe new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfileEmily Jiang
 
Architecture your android_application
Architecture your android_applicationArchitecture your android_application
Architecture your android_applicationMark Brady
 
Threads handlers and async task, widgets - day8
Threads   handlers and async task, widgets - day8Threads   handlers and async task, widgets - day8
Threads handlers and async task, widgets - day8Utkarsh Mankad
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsHassan Abid
 
Android training in mumbai
Android training in mumbaiAndroid training in mumbai
Android training in mumbaiCIBIL
 
Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Brian S. Paskin
 
An overview of Scalable Web Application Front-end
An overview of Scalable Web Application Front-endAn overview of Scalable Web Application Front-end
An overview of Scalable Web Application Front-endSaeid Zebardast
 

Semelhante a MIDlet Basics - The Lifecycle of a MIDlet Application (20)

Scmad Chapter03
Scmad Chapter03Scmad Chapter03
Scmad Chapter03
 
Lab 1 new
Lab 1 newLab 1 new
Lab 1 new
 
Session 3 J2ME Mobile Information Device Profile(MIDP) API
Session 3 J2ME Mobile Information Device Profile(MIDP)  APISession 3 J2ME Mobile Information Device Profile(MIDP)  API
Session 3 J2ME Mobile Information Device Profile(MIDP) API
 
Mobile Application Development MAD J2ME UNIT 2
Mobile Application Development  MAD J2ME UNIT 2Mobile Application Development  MAD J2ME UNIT 2
Mobile Application Development MAD J2ME UNIT 2
 
J2me Crash Course
J2me Crash CourseJ2me Crash Course
J2me Crash Course
 
Dependency injection in iOS
Dependency injection in iOSDependency injection in iOS
Dependency injection in iOS
 
RIBs - Fragments which work
RIBs - Fragments which workRIBs - Fragments which work
RIBs - Fragments which work
 
Spring Boot and Microservices
Spring Boot and MicroservicesSpring Boot and Microservices
Spring Boot and Microservices
 
Improving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesImproving app performance with Kotlin Coroutines
Improving app performance with Kotlin Coroutines
 
The new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfileThe new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfile
 
Architecture your android_application
Architecture your android_applicationArchitecture your android_application
Architecture your android_application
 
Threads handlers and async task, widgets - day8
Threads   handlers and async task, widgets - day8Threads   handlers and async task, widgets - day8
Threads handlers and async task, widgets - day8
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
 
Android - Anatomy of android elements & layouts
Android - Anatomy of android elements & layoutsAndroid - Anatomy of android elements & layouts
Android - Anatomy of android elements & layouts
 
Android training in mumbai
Android training in mumbaiAndroid training in mumbai
Android training in mumbai
 
Developing midlets
Developing midletsDeveloping midlets
Developing midlets
 
J2ME GUI Programming
J2ME GUI ProgrammingJ2ME GUI Programming
J2ME GUI Programming
 
Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Context and Dependency Injection 2.0
Context and Dependency Injection 2.0
 
Android101
Android101Android101
Android101
 
An overview of Scalable Web Application Front-end
An overview of Scalable Web Application Front-endAn overview of Scalable Web Application Front-end
An overview of Scalable Web Application Front-end
 

Mais de corneliuskoo

Expression Language in JSP
Expression Language in JSPExpression Language in JSP
Expression Language in JSPcorneliuskoo
 
13 Low Level UI Event Handling
13 Low Level UI Event Handling13 Low Level UI Event Handling
13 Low Level UI Event Handlingcorneliuskoo
 
12 High Level UI Event Handling
12 High Level UI Event Handling12 High Level UI Event Handling
12 High Level UI Event Handlingcorneliuskoo
 
07 Midlet On The Web
07 Midlet On The Web07 Midlet On The Web
07 Midlet On The Webcorneliuskoo
 
05 J2ME Wtk Command Line
05 J2ME Wtk Command Line05 J2ME Wtk Command Line
05 J2ME Wtk Command Linecorneliuskoo
 
04 J2ME Wireless Tool Kit
04 J2ME Wireless Tool Kit04 J2ME Wireless Tool Kit
04 J2ME Wireless Tool Kitcorneliuskoo
 
02a cldc property support
02a cldc property support02a cldc property support
02a cldc property supportcorneliuskoo
 
01 java 2 micro edition
01 java 2 micro edition01 java 2 micro edition
01 java 2 micro editioncorneliuskoo
 

Mais de corneliuskoo (14)

Basic JSTL
Basic JSTLBasic JSTL
Basic JSTL
 
Expression Language in JSP
Expression Language in JSPExpression Language in JSP
Expression Language in JSP
 
JSP
JSPJSP
JSP
 
Html Hands On
Html Hands OnHtml Hands On
Html Hands On
 
13 Low Level UI Event Handling
13 Low Level UI Event Handling13 Low Level UI Event Handling
13 Low Level UI Event Handling
 
12 High Level UI Event Handling
12 High Level UI Event Handling12 High Level UI Event Handling
12 High Level UI Event Handling
 
09 Display
09 Display09 Display
09 Display
 
07 Midlet On The Web
07 Midlet On The Web07 Midlet On The Web
07 Midlet On The Web
 
05 J2ME Wtk Command Line
05 J2ME Wtk Command Line05 J2ME Wtk Command Line
05 J2ME Wtk Command Line
 
04 J2ME Wireless Tool Kit
04 J2ME Wireless Tool Kit04 J2ME Wireless Tool Kit
04 J2ME Wireless Tool Kit
 
03 midp
03 midp03 midp
03 midp
 
02a cldc property support
02a cldc property support02a cldc property support
02a cldc property support
 
02 cldc
02 cldc02 cldc
02 cldc
 
01 java 2 micro edition
01 java 2 micro edition01 java 2 micro edition
01 java 2 micro edition
 

MIDlet Basics - The Lifecycle of a MIDlet Application

  • 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.