Sync up Palm OS with J2ME
Tutorial Details:
Sync up Palm OS with J2ME
Sync up Palm OS with J2ME
By: By Jeb Beich
Develop Palm HotSync conduits that interact with MIDP apps
ave you used any standalone applications for your mobile device lately? Probably not; most applications would be useless without some communication to the outside world. For example, doctors and nurses now use their PDAs to obtain the latest medical information stored in databases residing on the Internet. Also, a variety of handheld devices offer real-time securities-trading software. In short, handheld devices provide a portable way to view information that changes day-to-day, hour-to-hour, or minute-to-minute.
Java 2 Platform, Micro Edition (J2ME) features all the tools developers need to create platform-independent applications for mobile devices. Its MIDP (Mobile Information Device Profile) technology lets you quickly and easily bring complex, form-based applications to market for a wide range of handhelds.
We typically categorize handheld devices by their accompanying operating systems. The major players include Pocket PC and Windows CE, from Microsoft, and Palm OS, from Palm. Palm OS generally runs on a significantly cheaper device, which could explain Palm's market dominance and success as a highly desirable platform for application development. The low cost of Palm OS-based devices make them an excellent choice for application distribution, where a buyer purchases a device solely for application use. A doctor, for example, might use a PDA not to manage his schedule, but to access the various medical databases available for handhelds.
The HotSync technology for Palm OS is an application installed with the desktop software distributed with every Palm OS-based handheld. Using a serial or USB (universal serial bus) cable, HotSync transfers applications and data through conduits that plug in to the HotSync Manager. HotSync has achieved an overwhelming degree of success. Conduits can be found in applications ranging from Intellisync for Yahoo!?which synchronizes personal information to your Yahoo Profile?to Delta Airlines' conduit, which allows users to obtain flight information over the Internet.
Many mobile applications rely on some form of communication with a central information system, possibly residing on the Internet. For many handheld applications, wireless is not an option, but HotSync might be. Palm's wireless Internet provider, Palm.Net, is still relatively expensive at $40 per month for unlimited access, and many users might find themselves without coverage if they stray from metropolitan areas. If their applications are Web-clipped or stream-based and depend on a connection, users might find themselves out of luck. HotSync allows users to transfer data stored on their PDAs at their convenience.
Having said that, however, I must also point out that HotSync does not fall into the MIDP specification and hence is not supported by Sun Microsystems. The question now arises whether implementing a MIDP application that relies on a HotSync conduit is sound. Have you defeated the point of using Java to create a platform-dependent application, when you could have used the native C libraries? Hardly: By developing a HotSync-based MIDP application, you save yourself a considerable amount of time and money, and leave open the possibility to decouple yourself from Palm OS at any time. For example, with MIDP, you can easily create GUI (graphical user interface) elements such as drop-down boxes. MIDP developers need not concern themselves with the diligent search for memory leaks, which can crop up in C development. In addition, the MIDP specification supports the standard HTTP protocol, which can replace the HotSync logic when a situation calls for it. You should take advantage of the HotSync technology, as you can easily develop and distribute a wireless solution later.
Though MIDP lacks HotSync support, the spec does support persistent storage for Palm OS and maps handily to the persistent storage Palm currently uses. If you're developing any commercial-grade application, you usually need persistent storage?especially if your application communicates with another data source outside your handheld device. Once you get information from your data source, you need somewhere to put it. The MIDP specification includes persistent storage, which resembles the implementation used in Palm OS.
This article addresses how to combine your desire to use HotSync with your need for persistent storage to transfer your data source's information. I discuss the problems that arise when using a HotSync conduit to transfer information stored by a MIDP application on a Palm OS-based PDA and show you how to develop a HotSync conduit that successfully interacts with a MIDP application.
The first step in developing a Java-based HotSync conduit is acquiring the following tools:
Obviously, you'll need Sun's Java 2 SDK ; version 1.3 is preferred for conduit development.
Sun's J2ME Wireless Toolkit (JWTK) contains several handy tools and the necessary libraries to develop MIDP applications. Though not required for conduit development, the JWTK is needed for developing an application with which to test said conduit. Borland's JBuilder MobileSet offers an alternative to the JWTK.
Next, install Palm's latest version of the Conduit Development Kit (CDK) .
To run the sample MIDP application, you need the Palm OS Emulator .
Finally, install a null modem cable as specified in the CDK documentation.
We start by creating a simple MIDP application using the JWTK. This application tests the conduit, which we will create later, and highlights the inconsistencies when trying to use the CDK sample conduits with a MIDP application. We begin with a simple HelloMidlet , which displays a simple text field:
public HelloMidlet()
{
// Retrieve the display from the static display object
midletDisplay = Display.getDisplay(this);
// Initialize the doneCommand
doneCommand = new Command("DONE", Command.SCREEN, 1);
}
public void startApp()
{
Form f = new Form("Hello");
TextField hello = new TextField("Hello:",null, 20, TextField.ANY);
f.append(hello);
midletDisplay.setCurrent(f);
}
Note: For a comprehensive guide on creating MIDP applications, see Michael Cymerman's JavaWorld series " Device Programming with MIDP ."
As alluded to previously, this application needs persistent storage to be of any use.
How does Palm OS implement persistent storage?
The Palm OS features two database types: resource and record databases. We will deal exclusively with the latter. Each database consists of a header block, followed by an arbitrary data block. The header block contains:
Name
Creator ID
Type
Number of records
Last synchronization date
A creator ID is a four-character piece of code that can be registered with Palm to ensure uniqueness. Each record in the data block contains:
Record ID
Record category index
Record attributes
Record data
How does MIDP treat persistent storage?
A MIDP application maintains an RMS (Record Management System) record store for persistence storage. An RMS record store has only a one-dimensional structure with sequentially ordered data fields. In short, it's a list of byte arrays. A standard Palm OS record database also stores records this way.
You use the following methods to load and save the text field's contents of our HelloMidlet sample in an RMS record store:
public void loadText()
{
try
{
// Load the text field
RecordStore rs = RecordStore.openRecordStore("Hello" ,true);
if (rs.getNumRecords() > 0)
hello.setString(new String(rs.getRecord(1)));
rs.closeRecordStore();
}
catch(RecordStoreException rse) { System.out.println(rse); }
}
public void saveText()
{
try
{
// Save the text field
RecordStore rs =
RecordStore.openRecordStore("Hello" ,true);
byte[] bytes =
hello.getString().getBytes();
if (rs.getNumRecords() < 1) rs.addRecord(bytes,0,bytes.length);
else
rs.setRecord(1,bytes,0,bytes.length);
rs.closeRecordStore();
}
catch(RecordStoreException rse) { System.out.println(rse); }
}
The MIDP RMS specification maps almost exactly to Palm's persistent storage implementation, with just a few subtle differences: The call to openRecordStore() does more than simply open an existing record store. Upon attempting to open a nonexistent record store, the method call dynamically creates one. However, when a non-MIDP application attempts to access a database created by a MIDP application, it faces some difficulty. Specifically, the non-MIDP application has trouble dealing with this new database's header and name. The openRecordStore() method contains only one string argument, which is the record store's name, but additional items are needed for creating the header. For the above example, MIDP generates the following database header:
Database name: Hello-VM00
Creator ID: VM00
Application information block: byte[] { 0, (byte)'H', 0, (byte)'e', 0, (byte)'l', 0, (byte)'l', 0, (byte)'o' }
Type: RMSd
If a MIDP application using creator ID VM00 previously exists on the device, then VM01 would be used. This presents an interesting dilemma. If you desire access to the database using any source besides MIDP, it might prove difficult to determine the creator ID or database name. The solution: Use a conduit to create the database before the MIDP application ever accesses it.
What is a conduit?
According to Palm, conduits are:
Applications that plug in to HotSync technology, transferring information to and from a Palm Computing platform device, usually with some data manipulation in the process.
When a user drops a connected organizer into its cradle and presses the HotSync button, the HotSync Manager runs the conduits, which reside on the user's computer. Conduits also transfer, import, and export data, and install Palm OS applications. The Java conduits are geared towards two areas where development proves easier in Java than other languages: Internet/intrane
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: Sync up Palm OS with J2ME
View Tutorial: Sync up Palm OS with J2ME
Related
Tutorials:
Program Java devices -- An
overview - JavaWorld July 1999
Program Java devices -- An
overview - JavaWorld July 1999 |
Program your Palm in Java, Part 1: The PalmOS
Emulator - JavaWorld November
1999
Program your Palm in Java, Part 1: The PalmOS
Emulator - JavaWorld November
1999 |
Program your Palm in Java, Part 1: The PalmOS
Emulator - JavaWorld November
1999
Program your Palm in Java, Part 1: The PalmOS
Emulator - JavaWorld November
1999 |
J2ME: The next
major games
platform? - JavaWorld March 2001
J2ME: The next
major games
platform? - JavaWorld March 2001 |
Think small: Java on Compaq's iPAQ
Think small: Java on Compaq's iPAQ |
Build database-powered mobile applications on the
Java platform
Build database-powered mobile applications on the
Java platform |
Master J2ME for live data
delivery
Master J2ME for live data
delivery |
Sync up Palm OS with J2ME
Sync up Palm OS with J2ME |
Best tools for
mobile application development
Best tools for
mobile application development |
J2ME devices:
Real-world performance
J2ME devices:
Real-world performance |
Let the mobile
games begin, Part 2
Let the mobile
games begin, Part 2 |
High-availability mobile applications
High-availability mobile applications |
Wakeonlan
What is wakeonlan?
wakeonlan is a small OS independent java program that sends 'magic packets' to wake-on-lan enabled ethernet adapters and motherboards in order to switch on the called machine.It runs on every machine with an installed 1.4 java runtime. |
The HTML Renderer Shootout, Part 1
The HTML Renderer Shootout, Part 1
In this article, we will review 11 different HTML renderers, comparing their features, compliance, and speed; searching for the best one for any project. |
Getting Started With the Mobile 3D Graphics API for J2ME
This tutorial introduces the Mobile 3D Graphics API for J2ME, JSR 184. The article presents an overview, potential application areas, the differences between JSR 184 and two related APIs, the classes in the new optional package, the programming model, the |
J2ME Technology Turns 5!
In 2004 the Java 2 Platform, Micro Edition (J2ME) celebrated its fifth anniversary. This article presents where J2ME is today. |
Understanding MIDP System Threads
Describes the multi-threaded aspects of the J2ME application environment. Understanding the interactions between systems threads, user-interface and application threads will help in avoiding MIDlet deadlock. |
Updates to the Survey of J2ME Today
Give a consolidated big picture survey of J2ME terminology and technical origins. |
Java Technology Tutorials and Online Training
Learn the various Java technologies from the fundamentals of the Java programming language to web services and the J2EE platform through a variety of online tutorials and training classes. |
WAP Toolkits Motorola - Mobile ADK 1.1 Nokia - WAP Toolkit
WAP Toolkits Motorola - Mobile ADK 1.1 Nokia - WAP Toolkit
Tutorial
WAP Toolkits
T o develop any WAP application you have to download software essential for development. Although you can write and test your codes through our site for learning |
|
|
|