Writing Your First MIDlet Running JAVA on a Cell Phone - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

Writing Your First MIDlet Running JAVA on a Cell Phone

Description:

Cell Phones, Palms, Blackberry.... Pocket Fisherman? JAVA = one program, ... Cell Phones, Pagers, PDA's. MIDP. API and virtual machine to device ... Cell Phone ... – PowerPoint PPT presentation

Number of Views:207
Avg rating:3.0/5.0
Slides: 30
Provided by: CNF
Learn more at: http://www.pjug.org
Category:

less

Transcript and Presenter's Notes

Title: Writing Your First MIDlet Running JAVA on a Cell Phone


1
Writing Your First MIDletRunning JAVA on a Cell
Phone
  • Jon A. Batcheller
  • January 27, 2004

2
Overview
  • The MID
  • The CLDC MIDP
  • API
  • Developing Code
  • Emulation
  • Deployment

3
MID Mobile Information Device
  • Cell Phones, Palms, Blackberry.
  • Pocket Fisherman?
  • JAVA one program, multi-platforms
  • similar platforms - WORA

4
MIDP
  • Reduced JVM
  • J2ME Java 2 Mobile Edition
  • CLDC Connected Limited Device Configuration
  • CDC Connected Device Configuration full JVM
    imp.
  • MIDP Mobile Information Device Profile
  • Personal Java, Embedded Java, JavaPhone

5
MIDP
JAVA MIDP Apps
MIDP
CLDC
Native Apps
MID Native (SYMBIAN OS)
MID
6
CLDC
  • 128K to 512K total memory
  • Limited Power
  • Limited Connectivity (9600bps)
  • Reduced UI
  • Cell Phones, Pagers, PDAs

7
MIDP
  • API and virtual machine to device domain
  • java.lang
  • java.util
  • java.io
  • javax.microedition.io
  • javax.microedition.lcdui
  • javax.microedition.rms
  • javax.microedition.midlet

8
Development Tools
  • Sun Micro J2ME Wireless Toolkit
  • MIDP 1.0.3
  • Borland Sun Forte
  • Nokia Standalone JBuilder attachment
  • Need environment to compile (library), verify,
    package, emulate, and finally deploy

9
Writing our first MIDlet
  • Application written for the MIDP Profile
  • Must derive from javax.microedition.midlet.MIDlet
  • Must implement startApp(), pauseApp() and
    destroyApp()
  • Typically also implement a default constructor
    and a commandAction() from the CommandListener
    interface

10
MIDlet Lifecycle
11
HelloMIDlet.java
  • Extends MIDlet
  • Implements startApp, pauseApp, destroyApp
  • Like an Applet, need something and somewhere to
    display
  • Display .vs. Displayable
  • Foreground .vs. Background
  • Current Displayable

12
HelloMIDlet.java
  • Extends MIDlet
  • Implements startApp, pauseApp, destroyApp
  • Like an Applet, need something and somewhere to
    display
  • Display .vs. Displayable
  • Foreground .vs. Background
  • Current Displayable

13
Display Object
  • Displayable current Display.getDisplay(this).get
    Current()
  • Returns current Displayable
  • Typically in startApp(), look for current
    Displayable, if null, create own and set it as
    current.

14
HelloScreen
  • Displayable current Display.getDisplay(this).get
    Current()
  • Returns current Displayable
  • Typically in startApp(), look for current
    Displayable, if null, create own and set it as
    current.

15
HelloMIDlet.java
  • Compile
  • Note project library
  • Package
  • Emulate
  • Deploy
  • Test

16
Package
  • JAD
  • Versions JAD, CLDC, MIDP
  • Multiple MIDlets Suites
  • Other Classes
  • Other Files
  • JAR

17
JAD Java Application Descriptor
  • Usually a link on a WAP site
  • Info on the MIDlet
  • Most Important URL of the JAR
  • Downloaded to MID then user queried to download
    JAR

18
JAD Java Application Descriptor
  • MIDlet-Name HelloWorld
  • MIDlet-Version 0.0.1
  • MIDlet-Vendor Solidware, Inc
  • MicroEdition-Profile MIDP-1.0
  • MicroEdition-Configuration CLDC-1.0
  • MIDlet-Jar-URL HelloWorld.jar
  • MIDlet-Jar-Size 1592
  • MIDlet-1 HelloWorldApp, , HelloWorldApp

19
Deploy
  • JAD first
  • JAR on request
  • Methods
  • IR
  • BlueTooth
  • Email
  • WEB Over the Air
  • http//www.javac.com/index.wml

20
Emulate
  • Emulators part of toolkits Sun or Phone
  • http//developers.sun.com/techtopics/mobility/midp
    /articles/emulators
  • Debugging Environment
  • Interesting Behaviors

21
Test
  • Test
  • Download jad
  • Queries user if new or different version
  • Download jar
  • Execute Application
  • Review Application details

22
PropExample.java
  • Review Code
  • Emulators
  • Test

23
javax.microedition.lcdui
  • MIDP Low High-level APIs

Displayable
Canvas
Screen
Alert
Form
List
TextBox
24
javax.microedition.lcdui
  • Contents of Form and Alert Screens

Item
ChoiceGroup
DateField
Gauge
ImageItem
StringItem
TextField
25
UiDemo.java
  • Look and Feel
  • Bejeweled

26
javax.microedition.io
  • CLDC HTTP protocol!
  • Connection object
  • Content, Datagram, HTTP, Stream
  • Normal Stream I/O
  • Open with URL
  • Get input/output streams
  • Read/Write
  • Close

27
javax.microedition.io
  • HttpExample.java
  • Log Server2.java

28
javax.microedition.rms
  • Named record store
  • Access to byte array records
  • Add, Get, Store
  • Stock Ticker

29
Writing Your First MIDletRunning JAVA on a Cell
Phone
  • And the discussion continues at McMenamins
    Greenway Pub, 12272 SW Scholls Ferry Road
  • North on 217 next exit, then West
Write a Comment
User Comments (0)
About PowerShow.com