JavaME With Bluetooth GPS


I have been getting my hands dirty with the Java Mobile Edition (JavaME) platform and I have had my ups and downs with it. It is the first time I have made a mobile Java application but I have done Java for over 4 years.

My first project was to create an application which would “talk” to a bluetooth GPS device. This would give me experience with bluetooth as well as GPS technology and it did!

The Platform Background

J2ME was based on the Java language which has been cut down for the mobile platform. To do this they have removed a lot of the packages found in Java. The base version of Java it uses is 1.4 which is pretty old now considering Java Standard Edition (JavaSE) is on 1.6. All Java enabled devices using the JavaME platform has the base packages set by the Java committee which consists of some JavaSE packages and some JavaME specific packages. Over time new optional standard package specifications have been made and vendors can pick and choose which one they want to implement into their device. All of these optional standard packages are named JSR-xxx (Java Specification Requests) where “xxx” is a number. Like Java it is a specification and it can be implemented in different ways by different manufacturers.

My First JavaME Project

I was using a Motorola A1200 phone as my test phone because it was the phone I was using at the time. It’s not the most powerful phone but it does have some JSRs built in especially bluetooth (JSR-82). I wanted to use bluetooth technology in my program because it is a wireless standard in many devices and I wanted to use GPS because I didn’t want to make a program which would send and receive files.


The JSR packages makes developing Java applications a lot easier. There was one for bluetooth (JSR-82) and GPS (JSR-179) but unfortunately the Motorola A1200 didn’t support JSR-179. It was still possible to do GPS based program but more manual work was needed to get it to work. The first thing to do was to get the bluetooth side working before I could get it to talk to the GPS. This was the hardest part.


The program had to be multithreaded to handle graphical user interface (GUI) inputs and bluetooth processes like searching devices without it appearing to hang to the user. This was slightly odd to me because I mobile devices tend to only have single core processors so I didn’t know how well it would handle more than one thread. Also I wasn’t 100% comfortable with using threads because I hadn’t used them that much in my applications. In the end it turned out just fine. I had at times I had more than 2 threads (including the main thread) running.

Do bear in mind that most mobile phones at the time of writing are only single core processors with limited power to allocate processing time to each thread.


With bluetooth connected successfully I was able to get the NEMA-0183 data. It was a series of data values from the GPS device separated by commas. An example of this is:
All data sentences start with a “$” and followed by the type of data. Each data type contains different types of data but they may overlap in some areas. e.g two types of data strings may both contain speed.

Due to the paired down Java ME there are not a lot of text manipulation methods built into the framework and therefore a lot of methods need to be re-written to handle the GPS data.

Use Glenn Baddeley’s website to help you figure out which value is what in the comma delimited string.

Glenn Baddeley – GPS – NMEA sentence information

About Danny

I.T software professional always studying and applying the knowledge gained and one way of doing this is to blog. Danny also has participates in a part time project called Energy@Home [] for monitoring energy usage on a premise. Dedicated to I.T since studying pure Information Technology since the age of 16, Danny Tsang working in the field that he has aimed for since leaving school. View all posts by Danny → This entry was posted in Java, Mobile Phone, Programming and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.