Phones Programming in Java
Download
Report
Transcript Phones Programming in Java
Cosc 4730
Phone Programming in Java
An Introduction
Java: Blackberry vs Android
• Blackberry use JavaME with a lot of extensions
• We’ll cover the Blackberry JavaME with extensions
•
less JavaME, more Blackberry JavaME
•
If it doesn’t apply to a Blackberry, I won’t cover it.
• Android uses “Java”, except is closer in nature
to JavaME with Google/Android’s own twist.
• Because of this, I’ll teach how to code X for
Android as well as Blackberry
Java ME
Java Platform, Micro Edition
An environment for applications
Generally for mobile phones, PDA, TVs, and other
embedded devices.
Like Java Standard Edition (SE), applications
written for ME are portable across many devices.
But use each devices native capabilities
Java ME (2)
•
Java For Micro devices
•
Micro Device:
–
Limited processing Power
–
Limited Storage Capacity
–
No or Low Bandwidth Network Connection
•
Phones, PDAs, TV, Car Navigation systems, ...
Capabilities
•
Depends on device, but JavaME can:
–
Multimedia
•
–
Connectivity
•
–
HTTP, Network (Sockets, Datagrams), Bluetooth,
Infrared, Serial IO, Wifi and Cell Data Network
Gaming
•
–
audio/video playback/recording
Layers, Canvas, 3D support, Sprites
SMS, MMS, File Management, Database, GPS,
Personal Info Management, Security Services
Terms and Standards
Terms and Standards (2)
CLDC – Connected Limited Device
Configuration
Most mobile phones and their like.
Terms and Standards (3)
CLDC and MIDP (Mobile Information Device
Profile)
Most mobile devices in the last couple of use this
environment .
CLDC 1.1 (JSR 139) or CLDC 1.0 (JSR 30)
MIDP 2.0 (JSR 118) or MIDP 1.0 (JSR 37)
Note: MIDP 2.0 supports at least CLDC 1.0
Terms and Standards (4)
Also Java Technology for Wireless Industry
(JTWI) JSR 185. Currently JTWI 1.0
Includes MIDP 2.0
CLDC 1.0, but 1.1 may be used instead.
WMA 1.1 (JSR 120)
Wireless Messaging API, which provides access to text
messaging capabilities (usually SMS).
Optional MMAP 1.1
Mobile Media API for rendering and recording media
data.
Terms and Standards (4)
A few more we will run into (not a complete list)
Bluetooth and OBEX - JSR 82
Mobile 3D Graphics – JSR 184
Java API for bluetooth
Mobile 3D graphics API
SVG API – JSR 229
Scalable 2D Vector Graphics API
Architecture
•
Optional Packages
•
MMAPI, 3D API...
•
Profile
•
MIDP, PBP, App
•
Configuration
•
CLDC, CDC
–
JVM
CLDC
•
MIDP over CLDC is what most cell phones
use:
–
CLDC
•
•
•
•
•
•
•
No Floating point support
No Object finalization
No support for JNI or reflection
No thread groups or daemon thread
No application-defined class loaders
Implementation-defined error handling.
Class verification is done differently
MIDP
•
MIDP applications are called MIDlets
•
APIs for
–
Application management and control
–
User interface
–
Persistent storage
–
Networking
–
Timers
MIDlets
•
In a Nutshell and MIDlets is loaded
•
Then Startapp()
→ Active process running
→ PauseApp()
→ DestroyApp()
→ Paused Process
→ StartApp()
→ DestroyApp()
•
DestoryApp unloads MIDlets
CDLC Application
•
On some devices
–
An application can be created, instead of a
MIDlet
–
Application has a Main(), like normal Java
applications
–
MIDlet don't have main, instead extend the
MIDlet class
–
SmartPhones are more likely to have
Applications, instead of just MIDlets.
API references
•
Java ME techology API Documentation
•
http://java.sun.com/javame/referece/apis.jsp
–
Includes CLDC, CDC, and Sun optional
packages
–
Note: This sun generic JavaME and some
smartphones have added to JavaME
Jsr118 (MIDP 2.0)
•
•
User Interface Package
•
javax.microedition.lcdui: The UI API provides a set of features for implementation of user
interfaces for MIDP applications.
•
javax.microedition.lcdui.game: The Game API package provides a series of classes that enable
the development of rich gaming content for wireless devices.
Persistence Package
•
•
Application Lifecycle Package
•
•
javax.microedition.rms: The Mobile Information Device Profile provides a mechanism for MIDlets
to persistently store data and later retrieve it.
javax.microedition.midlet: The MIDlet package defines Mobile Information Device Profile
applications and the interactions between the application and the environment in which the
application runs.
Networking Package
•
javax.microedition.io: Classes for the Generic Connection framework.
Jsr118 (MIDP 2.0) (2)
•
•
Audio Package
•
javax.microedition.media: The MIDP 2.0 Media API is a directly compatible building block of the
Mobile Media API (JSR-135) specification.
•
javax.microedition.media.control: This package defines the specific Control types that can be
used with a Player.
Public Key Package
•
•
javax.microedition.pki: Certificates are used to authenticate information for secure Connections.
Core Packages
•
java.io: Provides classes for input and output through data streams.
•
java.lang: Provides classes that are fundamental to the Java programming language.
•
java.util: Contains the collection classes, and the date and time facilities.
For comparison
• Check the Java docs for jsr118 vs Java v6
• Java6: http://java.sun.com/javase/6/docs/api/
• Jsr118:
http://java.sun.com/javame/reference/apis/jsr118/
• JavaMe is very much a small subset of the java
language you are used to using.
• The language is there, but not everything you may
want to use.
Blackberry and android
• Blackberry's can use MIDlet, just like standard
JavaME phone
– But prefer a different method.
• base class is the application class, but is not a MIDlet.
application is closer in nature to a standard Java program,
then a JavaMe app. There is a Main class!
• uses MainScreen for each screen that the applications is
using.
– Note, you can have many screens.
• Android phones uses it own version of Java with
XML.
– Uses an Activity as base class
• very similar to MIDlet.
Android
•No JavaME Standards or
JSRs apply
•Uses an Activity as base
class, but similar to
MIDlets has OnCreate,
OnStart(), onResume(),
onStop()
•For more information:
•http://developer.android.c
om/guide/basics/what-isandroid.html
Android (2)
• Developer pages have lot of examples and
reference guides
– api reference guide:
http://developer.android.com/reference/android/
app/package-summary.html
– Resources and tutorials (where the helloworld
example came from)
• http://developer.android.com/resources/index.html
Q&A