• No results found

Development of Java ME

N/A
N/A
Protected

Academic year: 2021

Share "Development of Java ME"

Copied!
31
0
0

Loading.... (view fulltext now)

Full text

(1)

Y3

Y3

9

9

PDA

PDA

D

D

evelopment of Java ME

evelopment of Java ME

application

application

Jan

Jan VystrVystrččilil

České vysoké učení technické v Praze

(2)

Content

Content



What is Java ME



Low Level a High Level API



What is JSR



LBS

(3)

Jan Vystrčil

Development of Java ME application

3/29

Is Java ME still important?

(4)

What is Java ME?

What is Java ME?

 Officially Java Platform, Micro Edition  Formerly known as J2ME,

 Platform for devices with limited computing power

– Cell phones

– Handheld devices – Industrial controls – Set-top boxes

(5)

Jan Vystrčil

Development of Java ME application

(6)

What is KVM?

What is KVM?

 KVM – virtual machine for mobile devices  Supports only subset of JVM functions

– For ex. no floating point operation support

 Written in C

 K in KVM stands for Kilobyte

– Running on kilobytes of memory

(7)

Jan Vystrčil

Development of Java ME application

7/29

Configurations CDC and CLDC

Configurations CDC and CLDC

 CDC - Connected Device Configuration

 CLDC - Connected, Limited Device

(8)

Configuration CDC

Configuration CDC

 Using full Java VM  Typical requirements

– 32-bit processor

– Minimum 512K for the runtime environment – at least 256K to hold and run applications.

(9)

Jan Vystrčil

Development of Java ME application

9/29

Configuration CLDC

Configuration CLDC

 Using KVM

 Typical requirements

– 160 to 512 KB total memory available for the Java platform

– 16-bit or 32-bit processor

– low power consumption, often battery powered

– intermittent network connectivity (often wireless) with potentially limited bandwidth

(10)

Profile MIDP

Profile MIDP

 screen size of approximately (at least) 96x54

pixels

 display color depth of 1 bit

 one- or two-handed keyboard or touch screen

input device

 128 KB nonvolatile memory for MIDP components  8 KB nonvolatile memory for application-persistent

data

 32 KB volatile runtime memory for Java heap  two-way wireless connectivity

(11)

Jan Vystrčil

Development of Java ME application

11/29

Low Level and High Level API

Low Level and High Level API



Java ME supports two approaches of GUI

development

– Low Level API

•javax.microedition.lcdui.Canvas

– High Level API

(12)

Difference between Low Level and High Level API (1)

Difference between Low Level and High Level API (1)

 Low Level API

– Fully control graphical design of application (drawing on canvas)

– More difficult application development – Depends on target device (display size) – Limited portability on other devices

– Possible usage of numerical keypad (0-9) for controlling application (keyPressed events)

(13)

Jan Vystrčil

Development of Java ME application

13/29

Difference between Low Level and High Level API

Difference between Low Level and High Level API (2)(2)

 High Level API

– Application build up from set of UI components and user controls (forms, text boxes, check boxes etc.)

– Easy and rapid app. development

– Functionality independent on target device

– Easy portability on other devices (high compatibility) – Impossible to fully control graphical design of app.

(depends on device and implementation of MIDP in device) – Impossible -> left/right soft key (controlled by application

manager)

(14)

Difference between Low Level and High Level API

(15)

Jan Vystrčil

Development of Java ME application

15/29

Other

Other

UI

UI

toolkits

toolkits

 Based on Low Level API

(javax.microedition.lcdui.Canvas)

LWUIT

(Lightweight User Interface Toolkit) J2ME Polish

(16)

LWUIT

LWUIT

 Inspired by the architecture of Java Swing MVC  Features

– Basic set of components – Flexible layouts – Style – Theming  Runs on – JavaME – Android – BlackBerry

(17)

Jan Vystrčil

Development of Java ME application

17/29

What is JSR?

What is JSR?

 JSR = Java Specification Requests

 Formal documents that describe proposed

specifications and technologies for adding to the Java platform.

 Final JSR provides a reference implementation

that is a free implementation of the technology in source code form and Technology Compatibility Kit to verify the API specification

(18)
(19)

Jan Vystrčil

Development of Java ME application

19/29

Useful

Useful

JSR

JSR

s

s

 JSR 75 - PIM and FileConnection API

– Calendars – Filesystem

 JSR 82 - APIs for Bluetooth communication  JSR 179 - Location API

– Connection to GPS (A-GPS)

• Internal • Bluetooth

(20)

LBS

LBS

Location Based Services

Location Based Services

 Parsing of NMEA-0183 messages

– Used by GPS for communication with other devices – Complicated development

 Using Location API (JSR 179) if target device

implements it

(21)

Jan Vystrčil

Development of Java ME application

21/29 NMEA

NMEA -- National Marine Electronics AssociationNational Marine Electronics Association

 $GPRMC,162352,A,5053.10,N,00849.14,E,150.0,2 35.3,301294,,*10  $GPRMB,A,0.42,L,EDFN,EDFQ,5102.20,N,00840.80 ,E,010.5,330.1,-018.6,V*08  $GPWPL,5052.50,N,00848.88,E,EDFN*41  $GPGLL,5053.10,N,00849.12,E*6F  $PGRMZ,635,f,3*1B  $GPXTE,A,A,0.41,L,N*6B  $GPBWC,162352,5102.20,N,00840.80,E,330.2,T,, M,010.5,N,EDFQ*3C

(22)

NMEA

NMEA -- National Marine Electronics AssociationNational Marine Electronics Association

 NMEA message

 $GPGLL,4916.45,N,12311.12,W,225444,A,*1D

 Where:

 GLL Geographic position, Lat and Lon

 4916.46,N Latitude 49 deg. 16.45 min. North

 12311.12,W Longitude 123 deg. 11.12 min. West

 225444 Fix taken at 22:54:44 UTC

 A Data Active or V (void)

(23)

Jan Vystrčil

Development of Java ME application

23/29

LBS

LBS

using of Location API

using of Location API

...

// Set criteria for selecting a location provider: // accurate to 500 meters horizontally

Criteria cr= new Criteria(); cr.setHorizontalAccuracy(500);

// Get an instance of the provider

LocationProvider lp= LocationProvider.getInstance(cr);

// Request the location, setting a one-minute timeout Location l = lp.getLocation(60);

Coordinates c = l.getQualifiedCoordinates();

if(c != null ) {

// Use coordinate information double lat = c.getLatitude(); double lon = c.getLongitude(); }

(24)

MIDlet

MIDlet

vs. Java ME application

vs. Java ME application

start paused active destroyed startApp() pauseApp() destroyApp() not supported by S40, S60

public class Test extends MIDlet{ private boolean once = false; Pokus() { }

public void startApp() { if ( once == false ) {

once = true;

// resource allocation }

// other resource allocation // logic

}

public void pauseApp() { // resource release }

public void destroyApp() { // all resource release }

(25)

Jan Vystrčil

Development of Java ME application

25/29

MIDlet

MIDlet

vs. Java ME application

vs. Java ME application

start

running

main() class Test extends net.rim.device.api.ui.UiApplication {

public static void main(String[] args) { // resource allocation // logic // resource release } } end

(26)

MIDlet

MIDlet

vs. Java ME application

vs. Java ME application

start paused active destroyed startApp() pauseApp() destroyApp() start running main() end

(27)

Jan Vystrčil

Development of Java ME application

27/29

Java ME

Java ME

Architecture

Architecture

for

for

BlackBerry

BlackBerry

HW

Java Virtual Machine

BlackBerry API Java ME API

(MIDP 2.0, CLDC 1.1)

Java Application

Mixing Java ME GUI and BlackBerry GUI not possible • javax.microedition.lcdui

(28)

Java ME code performance

Java ME code performance

 use local variables

– faster access than to class members

 use threads for operation longer than 0.1 seconds

– filesystem, network, bluetooth, etc.

 access and declaration of data structures

– everything what can be private declare it as private – use final declaration

 memory allocation

– do not relay on efficiency of garbage collection

• do not allocate to much memory at once -> reuse objects

– use scalar types (int) instead of objects (Integer)

 optimize algorithms

(29)

Jan Vystrčil

Development of Java ME application

29/29

Java ME application deployment

Java ME application deployment

 JAR vs. JAD

– JAR: Manifest, Java classes, resource files – JAD: description about Java application

• needed for downloading Java application via network  On BlackBerry JAR -> COD

 On Android -> MicroEmulator

(30)

More

More

Resources

Resources

and

and

inspiration

inspiration

 http://pda.felk.cvut.cz

 Martin Rýzl - Úvod do Java Micro Edition

(31)

Jan Vystrčil

Development of Java ME application

31/29

References

Related documents

The main objective of this paper is to recommend an optimal system for remotely monitoring Photovoltaic (PV) and PV/wind hybrid power systems located on the Navajo Nation through

(B) the adsorption at a single site on the surface may involve multiple molecules at the same time.. (C) the mass of gas striking a given area of surface is proportional to the

It would be hard to find a more suitable example of Landau’s 1756 comment regarding ‘‘those who study the book of the Zohar and the Kabbalistic literature in public’’ 38 than

Fukakasu, Y., 2000, Innovation for Environmental Sustainability: A Background, Innovation and the Environment Ch.2, OECD Proceedings Green Paper on Integrated Product Policy,

Retrofitting of existing school buildings to improve their seismic resistance seems the most feasible solutions for their protection. Retrofitting an existing building to

Shan Foods position statement is “To the confident and convenience seeking woman of today, our wide range of Shan spice mixes offer premium quality products, made

The Cisco MDS 9506 multilayer director provides an open platform that delivers the intelligence and advanced features required to make multilayer intelligent SANs a reality,

The schools listed have met the requirements of RCW 28A.195 and are consistent with the State Board of Education rules and regulations in chapter 180-90 WAC. The Board will