2 - The Mobile Ecosystem and Java 2 Micro Edition
2 - The Mobile Ecosystem and Java 2 Micro Edition
Content
Mobile Ecosystem
Optional packages
Services
Applications
Application Frameworks
Operating Systems - Platforms
Devices
Networks
Operators
Operators
Tasks
Operator
Markets
Technology
Subscribers (in
millions)
1.
China Mobile
436.12
2.
Vodafone
United Kingdom,
Germany, Italy,
France, Spain
260.5
3.
Telefnica
Spain, Argentina,
Brazil, Chile,
Colombia,
188.9
4.
Amrica Mvil
United States,
Argentina, Chile,
Colombia, Paraguay,
172.5
5.
Telenor
Norway, Sweden,
Denmark, Hungary
143.0
6.
China Unicom
China
GSM, GPRS
127.6
7.
T-Mobile
Germany, United
States, United
Kingdom, Poland
126.6
8.
TeliaSonera
Norway, Sweden,
Denmark, Finland
115.0
9.
Orange
France, United
Kingdom, Switzerland,
Poland, Spain
111.8
10.
MTS
Russia, Ukraine,
Belarus, Uzbekistan,
Turkmenistan,..
91.7
MTN Group
Afghanistan, Benin,
Botswana, Cameroon,
Republic of Congo,
Cte dIvoire,
80.7
11.
Networks
2G
GSM
12.2 KB/sec
GPRS
Max 60 KB/sec
EDGE
59.2 KB/sec
HSCSD
57.6 KB/sec
3G
W-CDMA
14.4 MB/sec
UMTS
3.6 MB/sec
UMTS-TDD
16 MB/sec
TD-CDMA
16 MB/sec
HSPA
14.4 MB/sec
HSDPA
14.4 MB/sec
HSUPA
5.76 MB/sec
What is a Phone?
Nokia N96
Nokia N96
Connectivity
Nokia N96
Applications
Up to 5 megapixel (2592 x 1944 pixels) camera MPEG-4 Part 2 (H.263/SP), up to VGA 30 fps
Nokia N96
Music Features
Modu
4G - Fourth Generation
4G : Fourth-Generation
describes the next
complete evolution in
wireless communications
4G networks will come in
2012-2015
4G will be a fully IP-based
integrated system
4G will be capable of
providing between 100
Mbit/s and 1 Gbit/s
speeds both indoors and
outdoors, with premium
quality and high security.
Power consumption
limited computing power, low quality displays, small
disks due to limited battery capacity
CPU: power consumption ~ CV2f
C: internal capacitance, reduced by integration
V: supply voltage, can be reduced to a certain limit
f: clock frequency, can be reduced temporally
Loss of data
higher probability, has to be included in advance into
the design (e.g., defects, theft)
Limited user interfaces
compromise between size of fingers
and portability
integration of character/voice
recognition, abstract symbols
Limited memory and computing power
limited RAM, and CPU
Services
Applications
Application Frameworks
Operating Systems - Platforms
Devices
Networks
Operators
Cocoa Touch
Widgets run in WRT (not in the browser), a webapplication runtime environment that is part of the S60
Browser the phone must support it!
http://developer.symbian.org/wiki/index.php/Apps:Web_Apps_in_a_Nutshell
http://www.forum.nokia.com/Develop/Web/
http://wiki.forum.nokia.com/index.php/Category:Web_Runtime_(WRT)
The Web
script
CSS
Mobile Applications
SMS
Mobile Websites
Native Applications
Games
SMS
Examples
Mobile Websites
Native Applications
J2ME
Libraries
Java Language
Java Virtual Machine
Configuration
J2ME
Profile
Profiles
Optional Packages
Configuration
Configuration: CLDC
CLDC (Connected Limited Device Configuration): lowend consumer devices - cell phones, two-way pagers,
personal digital assistants (PDAs), organizers, home
appliances, and point of sale terminals
160 - 512 KB of total memory (160KB ROM and 32KB
RAM, minimum)
16-bit or 32-bit processor
Low power consumption and often operating with battery
power
Connectivity with limited bandwidth
Selected classes from: java.lang , java.io , java.util
Limited VM (called KVM):
NO Object finalization
NO JNI (Java Native Interface) or reflection
NO Thread groups or daemon threads
NO User Class loaders
J2SE
CDC
CLDC
File connection
Location API
Profiles
JTWI
JSR-185: Java Technology for Wireless Industry umbrella specification defined in 2003
Memory:
Mechanism for reading and writing from nonvolatile memory (to support persistence API)
Security
Approach:
CLDC 1.1
javax.microedition.lcdui
java.lang
javax.microedition.lcdui.game
java.lang.ref
javax.microedition.media
java.io
javax.microedition.media.control
java.util
javax.microedition.midlet
javax.microedition.io
javax.microedition.pki
javax.microedition.rms
Latest MIDP2.1 has minor differences with 2.0: making LCDUI layout
directive mandatory, javax.microedition.io.SocketConnection and
javax.microedition.io.HTTPConnection is no longer optional
MIDP 2.0
CLDC 1.0
Bluetooth API
(JSR-82 No OBEX)
Mobile Media API
(JSR-135)
Nokia UI API
Wireless Messaging API
(JSR-120)
N70 (2005)
MIDP 2.0
CLDC 1.1
Bluetooth API (JSR-82)
FileConnection and PIM API
(JSR-75)
JTWI (JSR-185)
Mobile 3D Graphics API
(JSR-184)
Mobile Media API
(JSR-135)
Nokia UI API
Web Services API
(JSR-172)
Wireless Messaging API
(JSR-120)
N95 (2007)
MIDP 2.0
CLDC 1.1
Advanced Multimedia
Supplements (JSR-234)
Bluetooth API (JSR-82)
FileConnection and PIM API
(JSR-75)
JTWI (JSR-185)
Location API (JSR-179)
Mobile 3D Graphics API
(JSR-184)
Mobile Media API (JSR-135)
Nokia UI API
Scalable 2D Vector Graphics API
(JSR-226)
Security and Trust Services API
(JSR-177)
SIP API (JSR-180)
Web Services API (JSR-172)
Wireless Messaging API
(JSR-205)
What device?
It is based on WURFL
The WURFL is an "ambitious" configuration file that
contains info about all known Wireless devices on earth
http://wurfl.sourceforge.net
Or go to http://www.forum.nokia.com/devices/
javax.microedition.io
System Classes
java.lang.Object
java.lang.Boolean
java.lang.Class
java.lang.Byte
java.lang.Runtime
java.lang.Short
java.lang.System
java.lang.Integer
java.lang.Thread
java.lang.Long
java.lang.Runnable
(interface)
java.lang.Float
java.lang.Double
java.lang.String
java.lang.Character
java.lang.StringBuffer
Collection Classes
java.lang.Throwable
java.util.Vector
java.util.Stack
java.util.Hashtable
java.util.Enumeration
(interface)
New in CLDC1.1
IO Classes
java.io.InputStream
java.util.Calendar
java.io.OutputStream
java.util.Date
java.io.ByteArrayInputStream
java.util.TimeZone
java.io.ByteArrayOutputStrea
m
Utility classes
java.io.DataInput (interface)
java.util.Random
java.io.DataOutput (interface)
java.lang.Math
java.io.DataInputStream
java.io.DataOutputStream
java.io.Reader
java.io.Writer
java.io.InputStreamReader
java.io.OutputStreamWriter
http://jcp.org/en/jsr/detail?
id=139
java.io.PrintStream
InputConnection
OutputConnection
StreamConnection
DatagramConnection
UPDDatagramConnection
HttpConnection
HttpsConnection
SecureConnection
ServerSocketConnection
Summary
MIDP does not run in the regular Java fashion using: main
(), System.exit()
Instead, we use MIDlet applications - which are subclasses
of javax.microedition.midlet.MIDlet
The application must extend this class to allow the
application management software to control the MIDlet:
control the MIDlet installation
Inspect existing Java applications stored on the device
be able to retrieve properties from the application
descriptor
Select and launch Java applications; respond to a
request for state change
Delete existing applications
A CLDC system may allow multiple Java applications to
executes concurrently (MIDP2.1) or restrict to one
application at a time (MIDP2.0).
Active
Destroyed
destroyApp
Pause
startApp
constructor
destroyApp
pauseApp
MIDlet Suite
What do we need
Java Platform, Standard Edition version 1.5 or
higher
Sun Java Micro Edition SDK This is a package of
tools for building and testing MIDlets
Text editor. This can be something as
rudimentary as Notepad (on Windows) or
something more elaborate (IDE environment as
NetBeans)
Following example is from
http://developers.sun.com/techtopics/mobility/
midp/articles/wtoolkit/
http://developers.sun.com/techtopics/mobility/
midp/articles/tutorial2/
Java ME SDK
Project
Uncheck
this
2
HelloWorld MIDlet
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class HelloMIDlet
extends MIDlet
implements CommandListener {
private Form mMainForm;
public HelloMIDlet() {
mMainForm = new Form("HelloMIDlet");
mMainForm.append(new StringItem(null, "Hello, MIDP!"));
mMainForm.addCommand(new Command("Exit", Command.EXIT, 0));
mMainForm.setCommandListener(this);
}
public void startApp() {
Display.getDisplay(this).setCurrent(mMainForm);
}
Hello World
Running
1) Build
The toolkit finds all the .java files in the src directory of
your project and 1) compiles them
3) JARing
Deploying MIDlets
Manifest Information
Hellosuite.jad
HitMIDlet.URL: http://localhost:8080/midp/hits
MIDlet-1: Hellosuite, Hellosuite.png, HelloMIDlet
MIDlet-2: HitMIDlet, , HitMIDlet
MIDlet-Jar-Size: 3016
MIDlet-Jar-URL: Hellosuite.jar
MIDlet-Name: Hellosuite
MIDlet-Vendor: Unknown
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0
Install NetBeans
HitServlet
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
code
MIDLET
import
import
import
import
java.io.*;
javax.microedition.io.*;
javax.microedition.lcdui.*;
javax.microedition.midlet.*;
code
MIDLET cont.
public void startApp() {
mDisplay = Display.getDisplay(this);
mDisplay.setCurrent(mMainForm);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void commandAction(Command c, Displayable s) {
if (c == mExitCommand)
notifyDestroyed();
else if (c == mConnectCommand) {
Form waitForm = new Form("Waiting...");
mDisplay.setCurrent(waitForm);
Thread t = new Thread() {
public void run() {
connect();
}
};
t.start();
}
}
MIDLEt cont
private void connect() {
HttpConnection hc = null;
InputStream in = null;
String url = getAppProperty("HitMIDlet.URL");
try {
hc = (HttpConnection)Connector.open(url);
in = hc.openInputStream();
int contentLength = (int)hc.getLength();
byte[] raw = new byte[contentLength];
int length = in.read(raw);
in.close();
hc.close();
// Show the response to the user.
String s = new String(raw, 0, length);
mMessageItem.setText(s);
}
catch (IOException ioe) {
mMessageItem.setText(ioe.toString());
}
mDisplay.setCurrent(mMainForm);
}
}
MIDlet Properties
Example:
Running
After 4 clicks on
the connect
command
http://java.sun.com/developer/technicalArticles/javame/midp3_enhance/
Exercises
Follow the slides and install, compile, and run the two
midlets: HelloMIDlet.java, HitMIDlet.java (the code is
on the course web site)