cosc 4730 phone programming in java an introduction

23
Cosc 4730 Phone Programming in Java An Introduction

Post on 21-Dec-2015

226 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Cosc 4730 Phone Programming in Java An Introduction

Cosc 4730

Phone Programming in Java

An Introduction

Page 2: 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

Page 3: Cosc 4730 Phone Programming in Java An Introduction

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

Page 4: Cosc 4730 Phone Programming in Java An Introduction

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, ...

Page 5: Cosc 4730 Phone Programming in Java An Introduction

Capabilities

• Depends on device, but JavaME can:

– Multimedia • audio/video playback/recording

– Connectivity• HTTP, Network (Sockets, Datagrams), Bluetooth,

Infrared, Serial IO, Wifi and Cell Data Network

– Gaming• Layers, Canvas, 3D support, Sprites

– SMS, MMS, File Management, Database, GPS, Personal Info Management, Security Services

Page 6: Cosc 4730 Phone Programming in Java An Introduction

Terms and Standards

Page 7: Cosc 4730 Phone Programming in Java An Introduction

Terms and Standards (2)

CLDC – Connected Limited Device Configuration Most mobile phones and their like.

Page 8: Cosc 4730 Phone Programming in Java An Introduction

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

Page 9: Cosc 4730 Phone Programming in Java An Introduction

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.

Page 10: Cosc 4730 Phone Programming in Java An Introduction

Terms and Standards (4)

A few more we will run into (not a complete list) Bluetooth and OBEX - JSR 82

Java API for bluetooth Mobile 3D Graphics – JSR 184

Mobile 3D graphics API SVG API – JSR 229

Scalable 2D Vector Graphics API

Page 11: Cosc 4730 Phone Programming in Java An Introduction

Architecture

• Optional Packages

• Profile

• Configuration

– JVM

• MMAPI, 3D API...

• MIDP, PBP, App

• CLDC, CDC

Page 12: Cosc 4730 Phone Programming in Java An Introduction

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

Page 13: Cosc 4730 Phone Programming in Java An Introduction

MIDP

• MIDP applications are called MIDlets

• APIs for

– Application management and control

– User interface

– Persistent storage

– Networking

– Timers

Page 14: Cosc 4730 Phone Programming in Java An Introduction

MIDlets

• In a Nutshell and MIDlets is loaded

• Then Startapp()

→ Active process running→ PauseApp()

→ DestroyApp()

→ Paused Process→ StartApp()

→ DestroyApp()

• DestoryApp unloads MIDlets

Page 15: Cosc 4730 Phone Programming in Java An Introduction

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.

Page 16: Cosc 4730 Phone Programming in Java An Introduction

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

Page 17: Cosc 4730 Phone Programming in Java An Introduction

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

• javax.microedition.rms: The Mobile Information Device Profile provides a mechanism for MIDlets to persistently store data and later retrieve it.  

• Application Lifecycle Package

• 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.  

Page 18: Cosc 4730 Phone Programming in Java An Introduction

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.

Page 19: Cosc 4730 Phone Programming in Java An Introduction

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.

Page 20: Cosc 4730 Phone Programming in Java An Introduction

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.

Page 21: Cosc 4730 Phone Programming in Java An Introduction

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.com/guide/basics/what-is-android.html

Page 22: Cosc 4730 Phone Programming in Java An Introduction

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

Page 23: Cosc 4730 Phone Programming in Java An Introduction

QA&