javame 01 overview
TRANSCRIPT
-
7/27/2019 JavaME 01 Overview
1/71
Java Platform, Micro Edition
Part 1 Introduction to Java ME, CLDCand MIDP
v3.0b 25 April 20091 Andreas Jakl, 2009
-
7/27/2019 JavaME 01 Overview
2/71
Disclaimer
These slides are provided free of charge at http://www.symbianresources.com andare used during Java ME courses at the University of Applied Sciences in Hagenberg,Austria at the Mobile Computing department ( http://www.fh-ooe.at/mc )
Respecting the copyright laws, you are allowed to use them:
for your own, personal, non-commercial use
in the academic environment In all other cases (e.g. for commercial training), please contact andreas.jakl@fh-
hagenberg.at
The correctness of the contents of these materials cannot be guaranteed. Andreas Jaklis not liable for incorrect information or damage that may arise from using thematerials.
This document contains copyright materials which are proprietary to Sun or variousmobile device manufacturers, including Nokia, SonyEricsson and Motorola. Sun, SunMicrosystems, the Sun Logo and the Java Platform, Micro Edition are trademarks orregistered trademarks of Sun Microsystems, Inc. in the United States and othercountries.
Andreas Jakl, 20092
http://www.symbianresources.com/http://www.fh-ooe.at/mchttp://www.fh-ooe.at/mcmailto:[email protected]:[email protected]:[email protected]:[email protected]:[email protected]://www.fh-ooe.at/mchttp://www.fh-ooe.at/mchttp://www.fh-ooe.at/mchttp://www.symbianresources.com/ -
7/27/2019 JavaME 01 Overview
3/71
About me: Andreas Jakl
Assistant Professor at the University ofApplied Sciences, Hagenberg since 2006
Teaching:
Introduction to Software Development (1st
semester BSc)
Java ME (2nd semester BSc)
Qt / Symbian OS (3rd semester BSc)
Bachelor Thesis Seminar (5th semester BSc)
Mobile Operating Systems (1st semester MSc)
Interaction Technology (2nd semester MSc)
Andreas Jakl, 20083
-
7/27/2019 JavaME 01 Overview
4/71
About me: Andreas Jakl
Experience:
Forum Nokia Champion (2007, 2008, 2009)
Founded company Mopius in 2004
Internship, Masters Thesis and summer jobs atSiemens / BenQ Mobile (Munich, R&D)
Studied Bachelor & Master ofDigital Media inHagenberg / Austria (2001 06)
Contact:Office A.005a (FH1, lower floor)
Andreas Jakl, 20094
mailto:[email protected]:[email protected]:[email protected]:[email protected]:[email protected] -
7/27/2019 JavaME 01 Overview
5/71
Java Platform
What is it all about?
5 Andreas Jakl, 2009
-
7/27/2019 JavaME 01 Overview
6/71
The Java Platform, Part 1 / 3
Java programming language
Compared to C++:
No pointers
Automatic garbage collection
Interfaces instead of multiple inheritance
Comes with an extensive library
Andreas Jakl, 20096
-
7/27/2019 JavaME 01 Overview
7/71
The Java Platform, Part 2 / 3
Virtual Machine (JVM)
Executes compiled Java bytecode (.class)
Available for many systems
Controls the code (security)
Often used for mobile phones:Kilobyte Virtual Machine (KVM)
Memory footprint starting at only 60 kB (+)
Now being replaced by Hotspot JVMs.
Andreas Jakl, 20097
-
7/27/2019 JavaME 01 Overview
8/71
The Java Platform, Part 3 / 3
Application Programming Interfaces (APIs)
Manifold libraries
e.g. UI, network, 3D, location based services, etc.
Andreas Jakl, 20098
-
7/27/2019 JavaME 01 Overview
9/71
Java?
In numbers:
> 6 Billion Java-enabled devices
2.6 Billion Java-enabled phones
(8 out of 10 shipped in 2008)
3.5 Billion Java Cards
20 Million Java set-top boxes
800 Million Java desktops
180 Operators deploying Java content
6 Million developers
Andreas Jakl, 20099
MSA M bil S i A hit t (JSR 248 d 249)
-
7/27/2019 JavaME 01 Overview
10/71
Java Editions
Andreas Jakl, 200910
Java 2
Platform,
Enterprise
Edition
(J2EE)
Java 2
Platform,
Standard
Edition
(J2SE)
Optional
PackagesOptional
Packages
CDC
Foundation
Profile
Personal Profile
Optional
Packages
Optional
Packages
MSA
CLDC Java Card
Personal
Basis
Profile
Servers &
enterprise
computers
Servers &
personal
computers
High-end PDAs,
TV set-top
boxes,
embedded
devices
Mobile
phones &
entry-level
PDAs
Smart
cards
Java Platform, Micro Edition
(Java ME)
JTWI
MIDP
MSA Mobile Service Architecture (JSRs 248 and 249)
JTWI Java Technology for the Wireless Industry, JSR 185
MIDP Mobile Information Device Profile
CDC Connected Device Configuration
CLDC Connected Limited Device Configuration
-
7/27/2019 JavaME 01 Overview
11/71
Java ME
Going Mobile
Andreas Jakl, 200911
-
7/27/2019 JavaME 01 Overview
12/71
Differences J2SE / Java ME (MIDP)
Java ME is mainly a subset of J2SE
But different UI- and event handling functionality
Less utility classes
(only Vector and Hashtable, no LinkedLists, )
Code runs on both platforms?
general algorithms: yes
But the whole application needs porting
Andreas Jakl, 200912
-
7/27/2019 JavaME 01 Overview
13/71
Name: J2ME or Java ME?
Official name:
Java Platform, Micro Edition (Java ME)
Former name:
J2ME
Andreas Jakl, 200913
-
7/27/2019 JavaME 01 Overview
14/71
Configuration
Defines Java Platform for different device classes:
CLDC
Limited user interface
Low computing power (usually with a battery)
Network with low bandwidth
CDC
Network connection with high bandwidth, possiblypersistent
Larger memory requirements
Andreas Jakl, 200914
-
7/27/2019 JavaME 01 Overview
15/71
CDC
Equivalent to Java SE 1.4.2 when combined with:
Foundation Profile (FP)
Extends CDC to Java SE 1.4.2, without graphics and UI
Personal Basis Profile (PBP)
Lightweight GUI support (AWT subset)
Personal Profile (PP)
Extends PBP with AWT components and Appled support Foundation for Java-based platforms:
(few) smartphones, Blu-Ray, Set-top boxes, etc.
Andreas Jakl, 200915
-
7/27/2019 JavaME 01 Overview
16/71
CLDC
Currently available in two versions:
1.0
In devices until ~ 2005 (at the latest)
1.1
Current standardSupports floating point(but mostly in software slow)
Important e.g. for GPS coordinate handling!
Used for:
Phones (!)
Consumer and entertainment devices
Embedded platforms, controllers, sensors
Sun SPOTs
Andreas Jakl, 200916
-
7/27/2019 JavaME 01 Overview
17/71
Profiles
Extension and more detailed specification for a
configuration
Contains APIs for UI, event handling, data storage,
networks, timers,
Minimum requirements for devices (screen size, input
possibilities, ...)
For mobile phones:Mobile Information Device Profile (MIDP)
Andreas Jakl, 200917
-
7/27/2019 JavaME 01 Overview
18/71
Profiles Major Differences
MIDP 1.0
Hardly any sound support,
limited graphics
Only HTTP, no Sockets
Many vendor-specific
extensions (bad!)
MIDP 2.0
Game API
Better network and
multimedia support
MIDP 2.1
Tries to improve fragmentationproblems (different version forevery phone)
Stricter specifications for
packages
MIDP 3.0 (JSR 271)
Multiple MIDlets can runconcurrently or in thebackground, auto-launch
More detailed specifications
More possibilities for the UI,support of secondary displays
Andreas Jakl, 200918
-
7/27/2019 JavaME 01 Overview
19/71
Sample Architecture of a Phone
Andreas Jakl, 200919
Profile: MIDP 2.0
Configuration: CLDC 1.1
Virtual Machine: HotSpot
Operating System
-
7/27/2019 JavaME 01 Overview
20/71
Java ME Examples
Motorola
MOTORAZR V3
CLDC 1.0
MIDP 2.0
Andreas Jakl, 200920
-
7/27/2019 JavaME 01 Overview
21/71
Java ME Examples
Nokia N70
CLDC 1.1
MIDP 2.0
Andreas Jakl, 200921
-
7/27/2019 JavaME 01 Overview
22/71
Java ME Examples
SonyEricsson P990i
CLDC 1.1
MIDP 2.0
CDC 1.0
Personal Profile
Andreas Jakl, 200922
-
7/27/2019 JavaME 01 Overview
23/71
Java ME Examples
Nokia N86 8MP
CLDC 1.1
MIDP 2.1
MSA (Subset)
Andreas Jakl, 200923
-
7/27/2019 JavaME 01 Overview
24/71
Java ME Examples
Andreas Jakl, 200924
Amazon Kindle 2
CDC
-
7/27/2019 JavaME 01 Overview
25/71
JSRs (Java Specification Requests)
JSR = CLDC, MIDP or libraries for additional features
Defined through:
Java Community Process (JCP)
Examples:
JSR 82: Bluetooth APIs
JSR 179: Location API
JSR 184: Mobile 3D API
JSR 226: Scalable 2D Vector Graphics API
Andreas Jakl, 200925
-
7/27/2019 JavaME 01 Overview
26/71
JSRs How Many?
Sample: supported JSRs of Nokia N86 8MP
Andreas Jakl, 200926
-
7/27/2019 JavaME 01 Overview
27/71
JSRs Games?
A racing game could require:
JSR 184 (3D Graphics)
3D world
JSR 135 (Mobile Media)
Sound
JSR 82 (Bluetooth)
P2P Gaming
JSR 180 (SIP)
P2P over the network
JSR 229 (Payment)
New forms of payment
Andreas Jakl, 200927
Asphalt 4: Elite Racing HD
Gameloft
-
7/27/2019 JavaME 01 Overview
28/71
JSRs Mapping Applications?
A mapping application could require:
JSR 226 (Vector Graphics)
Map visualization
JSR 179 (Location)
Where am I?
JSR 172 (Web Services)
Requesting data
JSR 75 (File and PIM)
Map an address
JSR 238 (Internationalization)
Global software
Andreas Jakl, 200928
Google Maps Mobile
Google
-
7/27/2019 JavaME 01 Overview
29/71
Write Once, Run Anywhere ?
Problems:
Different screen sizes
Bugs in manufacturers implementations (!)
Different hardware performanceWhich JSRs are supported? Bluetooth? SVG? Web services?
MIDP 2.0 isnt strict enough:
Different key codes for every manufacturer (softkeys, ...)
Are socket connections available? Which sound files are playable? Supported image formats?
Is double buffering supported?
Andreas Jakl, 200929
-
7/27/2019 JavaME 01 Overview
30/71
JTWI Fragmentation Solution?
Java Technology for the Wireless Industry (JSR 185)
First try of defining full API stack to reduce
fragmentation
Clarification of component JSR specificationsHowever: too small, too few APIs included
Bad licensing politics
Failed
Andreas Jakl, 200930
M bil S i A hit t
-
7/27/2019 JavaME 01 Overview
31/71
Mobile Service Architecture
(MSA, JSR 248)
Goal?
Umbrella specification, replace JTWI
Define a unified platform for majority of handsets
Spec leds: Nokia, Vodafone. Others heavily involved
Devices started to ship in 2007
With at least subset of MSA
Andreas Jakl, 200931
-
7/27/2019 JavaME 01 Overview
32/71
Features in MSA for CLDC
Andreas Jakl, 200932
Comms
JSR 82Bluetooth
JSR 180SIP
JSR 205MMS Messaging
JSR 120SMS Messaging
Graphics
JSR 226 2D ScalableVector Graphics
JSR 1843D Graphics
JSR 234 Mobile-media Supplement
JSR 135Mobile Media
Security &
Commerce
JSR 224Payment
JSR 177 Security &Trust Services
Application
Conectivity
JSR 211Content Handler
JSR 172Web Services
Personal
Information
JSR 179Location
JSR 75PIM & File
Application
Environment
JSR 185
JTWI
JSR 118
MIDP 2.0
JSR 238
I18N
VirtualMachine
JSR 139CLDC 1.1
Conditional APIs
JTWI APIs
-
7/27/2019 JavaME 01 Overview
33/71
MIDP 3.0
High-level goals
Add much-requested functionality over MIDP 2
Rework security model to support CLDC and CDC
Enables support ofMIDP 3 on CDC
Clarify spec and increase implementation consistency
Andreas Jakl, 200933
-
7/27/2019 JavaME 01 Overview
34/71
MIDP 3.0 Functional Enhancements
Concurrency (Multiple MIDlets at the same time)
Shared libraries (LIBlets)
Auto-start MIDlets
Idle screen MIDlets
Inter-MIDlet communication
Record store interchange format
User Interface improvements
...
Andreas Jakl, 200934
-
7/27/2019 JavaME 01 Overview
35/71
Mobile Service Architecture v2
Dynamic EnvironmentDownload new APIs to the handset
Place custom middleware on handset
Next revision of MSA 248
Supports both CLDC and CDC
Builds upon and requires MIDP 3.0
Adds multi-tasking and on-device service framework
Adds competitive user interface toolkit
Adds device segments: entry, standard, advanced
No final release date yet
Andreas Jakl, 200935
-
7/27/2019 JavaME 01 Overview
36/71
JavaFX
JavaFX (http://javafx.com integrated in NetBeans 6.5+)New UI libraries (graphics, media, web services)
Consistent experience across mobile, desktop, browser, TV, etc
Plus: use any Java library in JavaFX
Integrated with Java Runtime JavaFX Script
Simple declarative language, easier to learn
e.g., for artists to change sprite animation, without needing
software developerAdvantage to JavaScript / ActionScript: integration with Javareuse any Java library
Andreas Jakl, 200936
http://javafx.com/http://javafx.com/ -
7/27/2019 JavaME 01 Overview
37/71
JavaFX Mobile
Runs on Java ME (plus Android)
Mobile content with same tools as
Java FX
Availability?JavaFX Mobile Runtime needs to be
pre-installed on the phone
No phones released yet
Currently endorsed by:
SonyEricsson, LG
Andreas Jakl, 200937
-
7/27/2019 JavaME 01 Overview
38/71
Blu-Ray Disc Java: BD-J
Based on Java ME Personal Basis Profile & earlier Java TVspec
GUI environment suitable for consumer electronics (nokeyboard / mouse)
Strong media support
Applications?
Dynamic menu systems
Downloading additional content (subtitles, movie previews,etc.)
Games and other bonus material
Andreas Jakl, 200938
-
7/27/2019 JavaME 01 Overview
39/71
Java ME ApplicationsInternals
Andreas Jakl, 200939
-
7/27/2019 JavaME 01 Overview
40/71
Runtime environment
(KVM)
IDE
Code Application
Andreas Jakl, 200940
Source code (.java)
Compile
(javac)
.class-files
Preverification
.class-files
Packaging
Runtime
verification
Interpreter
.jar-file
(MIDlet Suite)
-
7/27/2019 JavaME 01 Overview
41/71
Preverification
Verification: check the integrity of the byte code atruntime
Too much for mobile devices, therefore:
pre-verification at compile time:Takes care of resource demanding checks
Simplifies runtime verification
Adds additional attributes to the .class file(5 15% increase in size)
Andreas Jakl, 200941
l
-
7/27/2019 JavaME 01 Overview
42/71
MIDlet Suite
Andreas Jakl, 200942
MIDlet Suite (.jar-Archiv):
- Defines access rights
- Possibility to share data (Record Stores)
- Shared static variables
MIDlet 1 MIDlet 2 MIDlet 3
MIDl S i
-
7/27/2019 JavaME 01 Overview
43/71
MIDlet-Suite
Andreas Jakl, 200943
.jar-archive
(MIDlet Suite)
Preverified .class-
file(s)
Resources
(icons, graphics
optional)
Manifest
.jad file(Application
descriptor, optional)
Information about
.jar
M if t
-
7/27/2019 JavaME 01 Overview
44/71
Manifest
Text file MANIFEST.MF
Contains meta information
Andreas Jakl, 200944
Manifest-Version: 1.0
MIDlet-Name: RealReplay
MIDlet-Description: RealReplay
MIDlet-Vendor: Mopius
MIDlet-Info-URL: http://www.mopius.com/
MIDlet-Version: 0.96.20
MIDlet-Icon: /res/icon.png
MIDlet-1:RealReplay,/res/icon.png,com.mopius.realreplay.RealReplayMIDlet
MicroEdition-Profile: MIDP-2.0
MicroEdition-Configuration: CLDC-1.1
A li ti D i t ( j d)
-
7/27/2019 JavaME 01 Overview
45/71
Application Descriptor (.jad)
Information about .jar contents
Allows to check compatibility before downloading .jar
Andreas Jakl, 200945
MIDlet-Name: RealReplay
MIDlet-Description: RealReplay
MIDlet-Vendor: Mopius
MIDlet-Info-URL: http://www.mopius.com/
MIDlet-Version: 0.96.20
MIDlet-Icon: /res/icon.png
MIDlet-1:
RealReplay,/res/icon.png,com.mopius.realreplay.RealReplayMIDlet
MicroEdition-Profile: MIDP-2.0MicroEdition-Configuration: CLDC-1.1
MIDlet-Jar-Size: 114185
MIDlet-Jar-URL: http://realreplay.mopius.com/files/realreplay.jarAdd.
Si i
-
7/27/2019 JavaME 01 Overview
46/71
Signing
Access to some telephone functionality (e.g. socketconnections, SMS) restricted: warning is displayed
every time
Solution:Sign the checksum of .jar in .jad-file with an own key
(certificate)
Own certificate is signed with root certificate of a
trusted certificate authority
Andreas Jakl, 200946
Why OTA for Deployment?
-
7/27/2019 JavaME 01 Overview
47/71
Why OTA for Deployment?
Some phones (Samsung, Sagem, BREW,...) do not supportinstalling MIDlets through the PC or Bluetooth
Only alternative:
Download directly through mobile phone
Over-the-Air (OTA) delivery
Andreas Jakl, 200947
Over the Air
-
7/27/2019 JavaME 01 Overview
48/71
Web ServerMobile Device
Over-the-Air
Andreas Jakl, 200948
AMS (Application
Management
Software)
JAD-Server JAR-Server NotificationServer
GET /midlet.jad
200 OK
200 OK
200 OK
GET /midlet.jar
POST /install-notify (900 Success)
HTTP
Optimization Obfuscation
-
7/27/2019 JavaME 01 Overview
49/71
Optimization Obfuscation
Original intention:Make reverse engineering more difficult
Code more difficult to read after de-compilation
Renames classes to a.class, b.class, Removes unused methods, variables, classes
Significant size reduction
Over-the-Air = expensive!MIDlet size restrictions in many phones
Improves speed (less code to load / parse)
Andreas Jakl, 200949
Obfuscation
-
7/27/2019 JavaME 01 Overview
50/71
Obfuscation
Original archive79,2 kB Obfuscated42,9 kB = 45% smaller!
Andreas Jakl, 200950
Developing for JavaME
-
7/27/2019 JavaME 01 Overview
51/71
Developing for JavaME
Highest priority: memory usage and speed
often very few classes, object orientation reduced to
a minimum, frequent use of static variables
But: todays phones have got more memory
Andreas Jakl, 200951
Example:Winter Sports
from Digiment
Open Source (GPL)
-
7/27/2019 JavaME 01 Overview
52/71
ToolsHow to develop:
52 Andreas Jakl, 2009
IDEs: Sun NetBeans
-
7/27/2019 JavaME 01 Overview
53/71
IDEs: Sun NetBeans
NetBeans (+ Mobility Pack)
Andreas Jakl, 200953
IDEs: NetBeans
-
7/27/2019 JavaME 01 Overview
54/71
IDEs: NetBeans
Very good integration for mobile projects:
Localisation
Conditional compilation
Packaging
UI-Designer, game builder,
Relatively high system requirements
Andreas Jakl, 200954
IDEs: Eclipse
-
7/27/2019 JavaME 01 Overview
55/71
IDEs: Eclipse
Eclipse + Plugin: EclipseME / MTJ (official plug-in)
Andreas Jakl, 200955
Is integrated in
IDEs: Eclipse
-
7/27/2019 JavaME 01 Overview
56/71
IDEs: Eclipse
Very good IDE
Helps a lot with programming errors
ME integration through Eclipse ME is average
Few Java ME specific tools / supportjust pure
Java
Andreas Jakl, 200956
Emulators
-
7/27/2019 JavaME 01 Overview
57/71
Emulators
Sun Java Wireless Toolkit for CLDC (2.5.2 / 3.0 EA)Tools for compiling, packaging and executing
Emulator:
Debugging
Error handling
Text output through console
Allows performance analysis
Simulates internet access and GPS
Download:
http://java.sun.com/javame/downloads/index.jsp
Andreas Jakl, 200957
Sun WTK
http://java.sun.com/javame/downloads/index.jsphttp://java.sun.com/javame/downloads/index.jsp -
7/27/2019 JavaME 01 Overview
58/71
Sun WTK
Andreas Jakl, 200958
Sample application
of NetBeans in the
WTK emulator
Manufacturer-Specific Emulators
-
7/27/2019 JavaME 01 Overview
59/71
p
Different Java ME implementations
Every device manufacturer has its own emulator:
Nokia:www.forum.nokia.com/Resources_and_Information/Tools/IDEs/
Sony Ericsson SDK for the Java ME Platformdeveloper.sonyericsson.com/site/global/docstools/java/p_java.jsp
Samsung
innovator.samsungmobile.com/
Motoroladeveloper.motorola.com/docstools/sdks/
Andreas Jakl, 200959
J2ME Polish
http://www.forum.nokia.com/Resources_and_Information/Tools/IDEs/http://developer.sonyericsson.com/site/global/docstools/java/p_java.jsphttp://innovator.samsungmobile.com/http://developer.motorola.com/docstools/sdks/http://developer.motorola.com/docstools/sdks/http://developer.motorola.com/docstools/sdks/http://developer.motorola.com/docstools/sdks/http://developer.motorola.com/docstools/sdks/http://developer.motorola.com/docstools/sdks/http://innovator.samsungmobile.com/http://developer.sonyericsson.com/site/global/docstools/java/p_java.jsphttp://developer.sonyericsson.com/site/global/docstools/java/p_java.jsphttp://developer.sonyericsson.com/site/global/docstools/java/p_java.jsphttp://www.forum.nokia.com/Resources_and_Information/Tools/IDEs/ -
7/27/2019 JavaME 01 Overview
60/71
Tools suite to address Java ME shortcomings:Own UI classes for custom, graphical UI
Build system, creates adapted version for specific handsets
Allows porting Java ME to Android Licensing:
Free for GPL products
1 commercial app: 990
Unlimited commercial apps: 14,990
http://www.j2mepolish.org/
Andreas Jakl, 200960
http://www.j2mepolish.org/http://www.j2mepolish.org/ -
7/27/2019 JavaME 01 Overview
61/71
Event-HandlingCommands
Andreas Jakl, 200961
Events The Big Picture
-
7/27/2019 JavaME 01 Overview
62/71
g
Andreas Jakl, 2009
* Requires registering the MIDlet
62
Listener
-
7/27/2019 JavaME 01 Overview
63/71
Implement the Listener-Interface to get informed:CommandListener: commandAction()
Notification when e.g. a menu item has been selected
ItemCommandListener: commandAction()
Used for events for individual items
ItemStateListener: itemStateChanged()
When an UI element has been changed
Andreas Jakl, 200963
Recap: Interfaces?
-
7/27/2019 JavaME 01 Overview
64/71
Interface: implemented by 1+ classes
Defines abstract methods and constants
But doesnt contain the implementation!
Implementing class has to override all defined methods
Important for generic development!
Caller does not need to know exact class type and name, but can work with theinterface type
More information at: http://en.wikipedia.org/wiki/Interface_(Java)
Andreas Jakl, 200964
public interface Predator {
boolean chasePrey(Prey p);
void eatPrey(Prey p);
}
public class Cat implements Predator {
public boolean chasePrey(Prey p) {
// programming to chase prey p (specifically for a cat)
}
public void eatPrey (Prey p) {
// programming to eat prey p (specifically for a cat)
}
}
Interface definition: Interface implementation:
Commands
http://en.wikipedia.org/wiki/Interface_(Java)http://en.wikipedia.org/wiki/Interface_(Java) -
7/27/2019 JavaME 01 Overview
65/71
Command = semantic information about an action( how can an action be executed?)
But no actual implementation of the action!
Contains:Short label
Long label (optional)
TypePriority
Andreas Jakl, 2009
One of them will be displayed on the
screen / in the menu, depending on the
available space
Intention of the command e.g. for
special placement on the device
For the order of commands, if more are
mapped to the same softkey. The lower
the priority, the more important it is.
65
Command-Types
-
7/27/2019 JavaME 01 Overview
66/71
Type DescriptionBACK Navigate to the previous screen (logically)
OK Standard positive answer
CANCEL Standard negative answer, e.g. used for OK & CANCEL
EXIT Exit the application
SCREEN Application specific command, e.g. Upload
HELP Request display of help text
ITEM Command is specific for items of the Screen or
for elements of a Choice component
STOP Stop currently running process / task
Andreas Jakl, 200966
ExitImplementation
e.g. like in the
Hello World-
-
7/27/2019 JavaME 01 Overview
67/71
Class HelloWorldMIDlet: implements CommandListener
Define new command (member variable):
private Command cmdExit;
Create it in the constructor:
cmdExit = new Command(Exit, Command.EXIT, 1);
frmMain.addCommand(cmdExit);
frmMain.setCommandListener(this);
Andreas Jakl, 2009
Exercise
67
Command Handling
-
7/27/2019 JavaME 01 Overview
68/71
Method defined in the base class CommandListener:
public void commandAction (Command c, Displayable d)
{
if (c == cmdExit)
{
destroyApp(true);
notifyDestroyed();
}
}
Andreas Jakl, 2009
true: forces shutdown, you have to
free resources!false: shtudown can be prevented by
the MIDlet if necessary.
... mainly important if the framework
wants / has to close down the app.
Inform the app. manager that our
MIDlet wants to be shut down.
68
Exit Softkey
-
7/27/2019 JavaME 01 Overview
69/71
Andreas Jakl, 200969
2 Softkeys, 3 Commands?
-
7/27/2019 JavaME 01 Overview
70/71
Commands in the menu placement depends on the phone:
Andreas Jakl, 2009
WTK 2.5 Nokia
Series 40
Nokia S60
70
-
7/27/2019 JavaME 01 Overview
71/71
Thanks for your attentionThats it!
Andreas Jakl, 200971