mobile applications with java me & blackberry

30
Mobile Applications with Java ME & BlackBerry

Upload: sumi

Post on 12-Jan-2016

65 views

Category:

Documents


0 download

DESCRIPTION

Mobile Applications with Java ME & BlackBerry. Overview. Java ME Networking Databases Java ME and the BlackBerry The BlackBerry wireless device Converting existing Java ME apps for the BlackBerry Deploying applications on the BlackBerry Blackberry AppWorld. http://cmer.cis.uoguelph.ca. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Mobile Applications with Java ME & BlackBerry

Mobile Applications with Java ME &

BlackBerry

Page 2: Mobile Applications with Java ME & BlackBerry

Overview

• Java ME

– Networking

– Databases

• Java ME and the BlackBerry

– The BlackBerry wireless device

– Converting existing Java ME apps for the BlackBerry

– Deploying applications on the BlackBerry

– Blackberry AppWorld

http://cmer.cis.uoguelph.ca 2

Page 3: Mobile Applications with Java ME & BlackBerry

Java Networking

• J2SE and J2EE networking APIs are not suitable for handheld devices

– Require several megabytes of memory to run

– Device manufacturers who work with circuit-switched networks require TCP support

– Device manufacturers who work with packet-switched networks require UDP support

– Other devices have specific mechanisms for communications

http://cmer.cis.uoguelph.ca 3

Page 4: Mobile Applications with Java ME & BlackBerry

CLDC Generic Connections

• A set of related abstractions at the programming level

• No abstractions for different forms of communications

• All connections are created using the Connector.open()

• If successful, it returns an object that implements one of the generic connection interfaces

http://cmer.cis.uoguelph.ca 4

Page 5: Mobile Applications with Java ME & BlackBerry

MIDP Generic Interfaces

• MIDP 1.0

http://cmer.cis.uoguelph.ca 5

Page 6: Mobile Applications with Java ME & BlackBerry

MIDP Generic Interfaces

• MIDP 2.0

http://cmer.cis.uoguelph.ca 6

Page 7: Mobile Applications with Java ME & BlackBerry

Connections: Examples

• HTTP:

Connector.open(“http://www.host.com”);

• Socket:

Connector.open(“socket://host.com:80”);

• Datagram:

Connector.open(“datagram://address:port”);

• File:

Connector.open(“file:/myfile.txt”);

http://cmer.cis.uoguelph.ca 7

Page 8: Mobile Applications with Java ME & BlackBerry

MIDP Connectivity

• It provides support for HTTP (HttpConnection)

• Why? HTTP can be implemented using IP protocols or non-IP protocols

http://cmer.cis.uoguelph.ca 8

Page 9: Mobile Applications with Java ME & BlackBerry

HttpConnection

• Part of the javax.microedition.io

• Defines the necessary methods and constants for an HTTP connection

HttpConnection c = (HttpConnection) Connector.open(“http://quotes.yahoo.com”);

C.setRequestMethod(HttpConnection.POST);

C.setRequestProperty(“Content-Language”, “en-CA”);

http://cmer.cis.uoguelph.ca 9

Page 10: Mobile Applications with Java ME & BlackBerry

Invoking Remote Applications

• A MIDlet may invoke remote applications:

– Fetching a page

– Invoking a CGI script (GET or POST method)

– Invoking a Servlet

http://cmer.cis.uoguelph.ca 10

Page 11: Mobile Applications with Java ME & BlackBerry

Advantages of CLDC Generic Connections

• Isolate the differences between the setup of one protocol and another

• Most of the application code remains the same regardless of the protocol you use

• Note: CLDC itself does not provide any protocol implementation

http://cmer.cis.uoguelph.ca 11

Page 12: Mobile Applications with Java ME & BlackBerry

Databases

• A persistent storage: a place to store the state of objects

• Facilities provided in J2SE and J2EE are not suitable for handheld devices

• MIDP provides a record-oriented database mechanism to persistently store data and retrieve it later

http://cmer.cis.uoguelph.ca 12

Page 13: Mobile Applications with Java ME & BlackBerry

MIDP’S RMS

• Lightweight record-oriented database

– Device independent API

– Unique recordID for each record within the store

– A record is an array of bytes

– Shared within MIDlet suite

– Support for enumeration, sorting, and filtering

• javax.microedition.rms

http://cmer.cis.uoguelph.ca 13

Page 14: Mobile Applications with Java ME & BlackBerry

MIDP - RMS Methods

• Record Store

openRecordStore, closeRecordStore, listRecordStore, deleteRecordStore, getRecordSize, getNumRecords

• Record Data

addRecord, deleteRecord, getRecord, setRecord, getRecordSize

• Record Selection

RecordEnumeration, RecordFilter, RecordComparator

http://cmer.cis.uoguelph.ca 14

Page 15: Mobile Applications with Java ME & BlackBerry

RMS: Record Stores

• To open a record store:

– RecordStoredb = RecordStore.openRecordStore(“myDB”, true);

• To close a record store:

– db.closeRecordStore();

http://cmer.cis.uoguelph.ca 15

Page 16: Mobile Applications with Java ME & BlackBerry

Create/Add a New Record

• To create a new record:

ByteArrayOutputStreambaos= new ByteArrayOutputStream();

DataOutputStreamdos = new DataOutputStream(baos);

dos.writeUTF(record);

Byte b[] = baos.toByteArray();

db.addRecord(b, 0, b.length);

http://cmer.cis.uoguelph.ca 16

Page 17: Mobile Applications with Java ME & BlackBerry

THE BLACKBERRY WIRELESS DEVICE

http://cmer.cis.uoguelph.ca 17

Page 18: Mobile Applications with Java ME & BlackBerry

The BlackBerry Smartphone

• The BlackBerry is a wireless handheld device developed by Research In Motion (RIM) in 1999.

• Supports push e-mail, mobile telephone, text messaging, internet faxing, web browsing and other wireless information services.

• Delivers information over the wireless data networks of mobile phone service companies.

• RIM currently offers BlackBerry e-mail service to non-BlackBerry devices, such as the Palm Treo, through the BlackBerry Connect software.

http://cmer.cis.uoguelph.ca 18

Page 19: Mobile Applications with Java ME & BlackBerry

Developing for the BlackBerry

• Unlike MIDlets, BlackBerry applications do not have a lifecycle

• Applications are compiled into .COD files rather than .JAD and .JAR

• In addition to full support of standard CLDC and MIDP APIs, RIM provides BlackBerry-specific extensions that enable you to develop applications with the look and feel of native applications

http://cmer.cis.uoguelph.ca 19

Page 20: Mobile Applications with Java ME & BlackBerry

Developing for the BlackBerry (Cont.)

• The BlackBerry APIs provide tighter integration for BlackBerry devices, and access to BlackBerry features for user interface, networking, and other capabilities

• CLDC, MIDP, and BlackBerry APIs may be used together in the same application – with the notable exception of user-interface APIs

• RIM's UI APIs provide greater functionality and more control over the layout of your screens and fields, but at a cost: Resulting MIDlets will be non-standard, so porting to other platforms will require more effort

http://cmer.cis.uoguelph.ca 20

Page 21: Mobile Applications with Java ME & BlackBerry

Java ME to BlackBerry

• Converting a J2ME MIDlet to a .COD involves the following steps:

– Download and install the RIM Java Development Environment

– Download and install Java SDK

– Copy the jad & jar files in question to the /bin/ directory of your RIM JDE installation

http://cmer.cis.uoguelph.ca 21

Page 22: Mobile Applications with Java ME & BlackBerry

Java ME to BlackBerry (Cont.)

– From the command line (make sure you are in the bin directory of your RIM JDE installation) type:rapc import=“$your_JDE_dir\lib\net_rim_api.jar" codename=$your_app -midlet jad=$your_app.jad $your_app.jar

where $your_JDE_dir is the directory of your RIM JDE installation, $your_app is the name of the MIDlet you're trying to convert, $your_app.jad is the name of the MIDlet descriptor and $your_app.jar is the name of the MIDlet jar file

http://cmer.cis.uoguelph.ca 22

Page 23: Mobile Applications with Java ME & BlackBerry

Java ME to BlackBerry (Cont.)

– The following files are generated:

• $your_app.debug

• $your_app.cod

– $your_app.debug may be discarded

– $your_app.cod is used to load the application onto the BlackBerry

http://cmer.cis.uoguelph.ca 23

Page 24: Mobile Applications with Java ME & BlackBerry

Java ME to BlackBerry (Cont.)

• Some MIDlets can't be directly translated into RIM .cod files because attributes in the .jad contain ASCII characters that are not valid in a project name in the RIM tool used to build .cod files.

• BlackBerry devices do not install from .jar and .jad files, but from proprietary binary formats created from the .jar and .jad files.

http://cmer.cis.uoguelph.ca 24

Page 25: Mobile Applications with Java ME & BlackBerry

Loading Applications on the BlackBerry

• To load the application onto the BlackBerry:

– Connect BlackBerry to computer via USB and from the command line (make sure you are in bin directory of your RIM JDE installation) type:

javaloader -usb load $your_app.cod

– The J2ME application will appear in the home screen on the BlackBerry.

http://cmer.cis.uoguelph.ca 25

Page 26: Mobile Applications with Java ME & BlackBerry

Removing Applications from the BlackBerry

• To remove an application from the BlackBerry:

– Connect BlackBerry to computer via USB and from the command line (make sure you are in bin directory of your RIM JDE installation) type:

javaloader -usb erase $your_app.cod

– The J2ME application will no longer appear in the home screen on the BlackBerry.

http://cmer.cis.uoguelph.ca 26

Page 27: Mobile Applications with Java ME & BlackBerry

Wiping the Blackberry Device

• Useful when transferring a device to another individual or cleaning the device after many application installations

• To wipe a Blackberry device of application data and third party applications enter the ‘Options’ menu, select ‘Security Options’ then ‘General Settings’, press the Blackberry button and select ‘Wipe Handheld’, confirm the dialog and type ‘blackberry’ to confirm

http://cmer.cis.uoguelph.ca 27

Page 28: Mobile Applications with Java ME & BlackBerry

Blackberry AppWorld

• The Blackberry AppWorld allows mobile application developers to distribute their applications to customers

• AppWorld helps provide Blackberry developers a unified location to distribute their Blackberry applications and helps promote development on the Blackberry device

• RIM provides technical testing of applications and provides feedback on the suitability of the applications as well as information regarding the individuals who download your application

http://cmer.cis.uoguelph.ca 28

Page 29: Mobile Applications with Java ME & BlackBerry

Java ME and BlackBerry Tools

• Sun’s Wireless Toolkit:

– http://java.sun.com/products/sjwtoolkit

• NetBeans(Mobility Pack)

– http://www.netbeans.org

• RIM’sBlackBerryJDE:

– http://www.rblackberry.com/developers

http://cmer.cis.uoguelph.ca 29

Page 30: Mobile Applications with Java ME & BlackBerry

Resources

• Java ME (J2ME): – http://java.sun.com/javame/index.jsp

• CLDC and KVM: – http://java.sun.com/products/cldc

• MIDP: – http://java.sun.com/products/midp

• Sun Microsystems Developer Network:– java.sun.com/wireless

• WirelessDevNetDeveloper Portal:– www.wirelessdevnet.com

http://cmer.cis.uoguelph.ca 30