1 / 31

J2ME MIDP2.0

J2ME MIDP2.0. An Introduction. What is J2ME?. Java 2 Micro Edition Specially cut down version of Java for mobile devices, such as mobile phones, PDAs, Set Top Boxes.

KeelyKia
Download Presentation

J2ME MIDP2.0

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. J2ME MIDP2.0 An Introduction

  2. What is J2ME? • Java 2 Micro Edition • Specially cut down version of Java for mobile devices, such as mobile phones, PDAs, Set Top Boxes. • It combines a resource-constrained JVM (Java Virtual Machine) and a set of Java APIs for developing applications for mobile devices. J2ME 1 – Week 6

  3. J2ME Configurations - 1 • 2 configurations • Connected Limited Device Configuration (CLDC) • 16-32bit • 160kb – 512 kb memory • Battery powered • Inconsistent • Small-bandwidth network wireless connection • May not have user interface (UI) • Pagers, PDA, cell phone, Dedicated terminals, handheld consumer devices with 128kb and 512of memory J2ME 1 – Week 6

  4. J2ME Configuration - 2 • Connected Device Configuration (CDC) • >= 2Mb memory • Implement the complete JVM also called the Compact Virtual Machine (CVM) • Digital setup boxes • home appliances • navigation systems • point-of-sale terminal • smart phone J2ME 1 – Week 6

  5. What is J2ME? • In CLDC, many features such as floating-point support are missing, due to capabilities of the device. • Extra features such as a GameAPI are now included for mobile development. • Unlike windows, a java virtual machine comes pre-installed on the phone. J2ME 1 – Week 6

  6. Why J2ME? • Supported by over 1Billion handsets • Device independent J2ME 1 – Week 6

  7. J2ME Development • Sun Wireless Toolkit WTK • Several IDEs Available: • NetBeans • Eclipse • Sun One • Borland JBuilder J2ME 1 – Week 6

  8. Core and Optional Packages J2ME can be divided in 3 parts: J2ME 1 – Week 6

  9. CLDC / CDC • A profile is a superset of a configuration, of which there are currently two: Connected Limited Device Configuration: CLDC and Connected Device Configuration: CDC J2ME 1 – Week 6

  10. MIDP • It implements a profile such as MIDP for mobile devices or foundation profile for embedded devices like set-top boxes J2ME 1 – Week 6

  11. Optional Packages • Several Optional Packages: • MMAPI • PIM / File Connection • WMAPI • 3D API • Bluetooth J2ME 1 – Week 6

  12. Fragmentation? • Implementation of optional packages varies across devices and manufacturers. • Nokia and Sony Ericsson provide consistent approach • Other manufacturers vary See comparative table on blackboard J2ME 1 – Week 6

  13. Specifications • Visit developer sites for device specifications J2ME 1 – Week 6

  14. Official Developer Sites Nokiawww.forum.nokia.com Samsunghttp://developer.samsungmobile.com/eng/front_zone/bbs/bbs_main.jsp?p_menu_id=1500 Motorola http://developer.motorola.com/ Sony Ericssonhttp://developer.sonyericsson.com/ Microsoft http://www.microsoft.com/windowsmobile/developers/default.mspx Blackberry http://www.blackberry.com/developers/index.shtml Siemens https://market.benqmobile.com/portal/main.aspx?LangID=0&pid=1 Orange Partner: http://www.orangepartner.com/site/enuk/home/p_home.jsp J2ME 1 – Week 6

  15. MIDlets • A Java program created for Mobile Devices (J2ME application) • MIDlets will (should) run on any device that implements J2ME MIDP • Like all Java programs, MIDlets are "compile once, run anywhere“ • MIDlet = .jar file J2ME 1 – Week 6

  16. MIDlet Reqs • A MIDlet has to fulfill the following requirements in order to run on a mobile phone: • The main class needs to be a subclass of javax.microedition.midlet.MIDlet • The MIDlet needs to be packed inside a .jar file (e.g. by using the jar-tool) • The .jar file needs to be pre-verified by using a preverifier. J2ME 1 – Week 6

  17. MIDlet Development Process J2ME 1 – Week 6

  18. MIDlet • A MIDlet is a set of classes designed to be run and controlled by the application management software • The application must extend this class to allow the AMS to control the MIDlet and to be able to retrieve properties from the application descriptor and notify and request state changes. J2ME 1 – Week 6

  19. MIDlet • The methods of this class allow the AMS to: • Create; • Start; • Pause; • and destroy a MIDlet. J2ME 1 – Week 6

  20. MIDlet Life Cycle J2ME 1 – Week 6

  21. Basic MIDlet MainMidlet.java //classes needed for MIDlet execution import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class MainMidlet extends MIDlet { public void startApp() { //start application from here //set the display } public void pauseApp() { //pause application } public void destroyApp(boolean unconditional) { //stop application } } J2ME 1 – Week 6

  22. MIDlet Functions A MIDlet needs to have the following functions in order to compile: startApp() – this runs when the MIDlet is started pauseApp() – this runs when the application is paused e.g. incoming call destroyApp() – this runs when the MIDlet / application is closed J2ME 1 – Week 6

  23. MIDlet States and Events J2ME 1 – Week 6

  24. MIDP GUI - Display Classes • Different from J2SE (Java Standard Ed.) • AWT and swing not implemented! J2ME 1 – Week 6

  25. High Level GUI • Screens, forms, lists, choice, text fields… • all of these inherit: javax.microedition.lcdui.Screen • Easy to program – pre-defined objects • Not very flexible – difficult to customize objects • Unsuitable for multimedia applications although it can be used for menus and settings J2ME 1 – Week 6

  26. GUI Display Classes J2ME 1 – Week 6

  27. Examples of High-Level GUI J2ME 1 – Week 6

  28. Low Level GUI • Canvas • Base class for writing applications that need to handle low-level events and to issue graphics calls for drawing to the display. • Full control over screen display. • Ability to process events and key presses. J2ME 1 – Week 6

  29. Low Level GUI • Canvas: Game Canvas (A subclass of Canvas) • provides the basis for a game user interface • provides game-specific capabilities such as: • an off-screen graphics buffer • the ability to query key status. J2ME 1 – Week 6

  30. /* * MainMidlet.java */ import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class MyMidlet extends MIDlet { //variable for display private Display display; //create new MyGameCanvas private MyGameCanvas mgc = new MyGameCanvas() ; public void startApp() { // find current display this.display = Display.getDisplay( this ) ; // attach myGameCanvas to display this.display.setCurrent(mgc) ; }//start app public void pauseApp() { }//pause app public void destroyApp(boolean unconditional) { // Clear up resourses notifyDestroyed() ; }//destroyApp }//end class /* * MyGameCanvas.java */ //import necessary graphics classes: import javax.microedition.lcdui.game.*; import javax.microedition.lcdui.* ; public class MyGameCanvas extends GameCanvas{ /** Creates a new instance of MyGameCanvas */ public MyGameCanvas() { super(true) ; }//constructor public void paint(Graphics g) { /*clear the screen call this method anytime you wish to refresh the gfx*/ flushGraphics(); //set the colour to black in RGB values g.setColor(0,0,0); /* Draws the Hello world string at x=0, y=0 location, the text is aligned to the top left of the screen.*/ g.drawString("Hello World!!!",0,0,Graphics.TOP|Graphics.LEFT); }//paint }//class J2ME 1 – Week 6

  31. J2ME Online Resources • Forum Nokia • Orange • Sony Ericsson • Motorola • Sun J2ME • Several others available… J2ME 1 – Week 6

More Related