Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Scmad Chapter03

1,579 views

Published on

SCMAD Review - Chapter 03 - Only for studies purposes

Published in: Business, Technology
  • Be the first to comment

  • Be the first to like this

Scmad Chapter03

  1. 1. By Marcel Caraciolo http://mobideia.blogspot.com Chapter 03 – MIDP and MIDlets SCMAD Certification 45mm 61mm
  2. 2. Agenda <ul><li>Introduction to MIDP </li></ul><ul><li>MIDP – API’s </li></ul><ul><li>MIDlets and MIDlets Suites </li></ul>
  3. 3. MIDP: Mobile Information Device Profile <ul><li>Depends on CLDC </li></ul><ul><li>Designed for mobile phones </li></ul><ul><li>Devices must have: </li></ul><ul><ul><li>Screen (either mono, gray scale or color) </li></ul></ul><ul><ul><li>Keyboard or touchscreen </li></ul></ul><ul><ul><li>Network (limited) </li></ul></ul><ul><ul><li>Sound (rudimentary) </li></ul></ul>
  4. 4. MIDP – API’S <ul><li>Provides API’s for: </li></ul><ul><ul><li>Application life cycle and installation management </li></ul></ul><ul><ul><li>User interface </li></ul></ul><ul><ul><li>2D games </li></ul></ul><ul><ul><li>Multimedia </li></ul></ul><ul><ul><li>Persistence </li></ul></ul><ul><ul><li>Networking (HTTP 1.1 and HTTPS required) </li></ul></ul><ul><ul><li>Notifications via alarm and network </li></ul></ul><ul><ul><li>Security: Permissions and application signing </li></ul></ul><ul><ul><li>Timers </li></ul></ul>
  5. 5. MIDP – MIDlet Suites <ul><li>MIDP applications are packaged as MIDlet Suites. A </li></ul><ul><li>suite is composed of: </li></ul><ul><ul><li>JAR file with one or more MIDlets. ALL the classes that the </li></ul></ul><ul><ul><li>application depends on (the application can not depend on </li></ul></ul><ul><ul><li>classes from other JAR) and a Manifest.mf with this Suite’s </li></ul></ul><ul><ul><li>metadata. </li></ul></ul><ul><ul><li>JAD descriptor file (not required) with Suite’s metadata (JAD is </li></ul></ul><ul><ul><li>not packaged inside the JAR). </li></ul></ul><ul><ul><li>Samples: /etc/HelloWorld.jad, /etc/Manifest.mf </li></ul></ul>
  6. 6. MIDP – Manifest.mf
  7. 7. MIDP – Application descriptor (.jad)
  8. 8. MIDP – MIDlet Suites <ul><li>The application life cycle is controlled by the device. You </li></ul><ul><li>will not write a “publicstaticvoidmain” method on a </li></ul><ul><li>MIDlet, and calls to System.exit() throw a </li></ul><ul><li>SecurityException . </li></ul><ul><li>All the classes from a Suite are executed on the same VM </li></ul><ul><li>and share resources (e.g. a static getInstance() singleton is </li></ul><ul><li>shared between all the objects in the suite). </li></ul>
  9. 9. MIDP – MIDlet Suites
  10. 10. MIDP – MIDlet Suites
  11. 11. MIDP – MIDlet Suites - Review
  12. 12. MIDP - MIDlets <ul><li>Control the java application life cycle </li></ul><ul><li>Extend the javax.microedition.midlet.MIDlet </li></ul><ul><li>Sample: studyguide.cap03.HelloWorldMIDlet </li></ul><ul><li>You must code a constructor and three methods: </li></ul><ul><ul><li>startApp </li></ul></ul><ul><ul><li>pauseApp </li></ul></ul><ul><ul><li>destroyApp </li></ul></ul><ul><li>Methods shall execute quickly </li></ul><ul><li>Initializations shall be done on the constructor </li></ul><ul><li>MIDlet class must have a no-args constructor. </li></ul>
  13. 13. MIDP - startApp() <ul><li>Called when the application is started or re-activated </li></ul><ul><li>May throw MIDletStateChangeException , signalling errors </li></ul><ul><li>when the application was being activated (Temporary </li></ul><ul><li>error. User may try again later) </li></ul><ul><li>Define a screen that will be shown at initializations and re- </li></ul><ul><li>activations. </li></ul>
  14. 14. MIDP - pauseApp() <ul><li>Called by the device to signal the application will be put on </li></ul><ul><li>hold (e.g. when the device receives an incoming call). </li></ul><ul><li>Applications shall release all the resources that will not be </li></ul><ul><li>in use while the application is paused. </li></ul>
  15. 15. MIDP - destroyApp(unconditional) <ul><li>Notifies that the application is going to be finished. This </li></ul><ul><li>MIDlet’s instance will not be reused. If the application is </li></ul><ul><li>started again, a new object will be created. </li></ul><ul><li>If “unconditional “is false , the method may throw a </li></ul><ul><li>MIDletStateChangeException , so the application remains </li></ul><ul><li>running. This can be used, for instance, when the </li></ul><ul><li>application wants to confirm that the modified data may </li></ul><ul><li>be lost. If it’s true , the exception shall not be thrown </li></ul><ul><li>and the application will be finished. </li></ul><ul><li>May be called by the MIDlet itself before asking it’s </li></ul><ul><li>termination. </li></ul>
  16. 16. MIDP - MIDlet life cycle
  17. 17. MIDP - Graphic user interface model <ul><li>javax.microedition.lcdui.Display </li></ul><ul><ul><li>setCurrent : Defines the “javax.microedition.lcdui.Displayable” to </li></ul></ul><ul><ul><li>be shown. </li></ul></ul><ul><ul><li>Instance is found by calling Display.getDisplay( midlet ) and it is </li></ul></ul><ul><ul><li>valid through all the MIDlet’s life. </li></ul></ul>
  18. 18. MIDP - Super Class methods <ul><li>notifyDestroyed(), notifyPaused(), resumeRequest(): </li></ul><ul><ul><li>Called by the MIDlet to indicate that the application wishes to </li></ul></ul><ul><ul><li>change its state, to finalize, pause o re-start the execution (an </li></ul></ul><ul><ul><li>example of re-initialization request is a thread left running on </li></ul></ul><ul><ul><li>the background requesting to put the application on foreground </li></ul></ul><ul><ul><li>again). </li></ul></ul><ul><li>MIDlet.getAppProperty(key): </li></ul><ul><ul><li>Returns the value of an application property </li></ul></ul><ul><ul><li>Properties are defined on the JAD or manifest file </li></ul></ul><ul><ul><li>Applications may create its own properties, as long as they don’t </li></ul></ul><ul><ul><li>start with “MIDlet-” or “MicroEdition-” </li></ul></ul><ul><ul><li>Shall not be confused with System.getProperty(), which returns a </li></ul></ul><ul><ul><li>system property from the device (e.g. hostname, supported </li></ul></ul><ul><ul><li>OP’s, phone numbers). </li></ul></ul>
  19. 19. MIDP - Super Class methods
  20. 20. MIDP - Mandatory Attributes
  21. 21. MIDP - Optional Attributes
  22. 22. Future Work <ul><li>Next Chapter: </li></ul><ul><ul><li>MIDP -User Interface </li></ul></ul><ul><ul><li>API’s : High level, Low level, game </li></ul></ul><ul><ul><li>Displayable </li></ul></ul><ul><ul><li>Command </li></ul></ul><ul><ul><li>CommandListener </li></ul></ul><ul><ul><li>Ticker </li></ul></ul><ul><ul><li>Classes </li></ul></ul>
  23. 23. References <ul><li>ALVES F. Eduardo. SCMAD Study Guide, </li></ul><ul><li>27/04/2008. </li></ul><ul><li>JAKL Andreas, Java Platform, Micro Edition Part </li></ul><ul><li>01 slides, 12/2007. </li></ul><ul><li>Sun Certification Mobile Application Developer </li></ul><ul><li>Website: [http://www.sun.com/training/certification/java/scmad.xml]. </li></ul>

×