02-18-2010 02:55 PM
I am developing an application for BB (OS v4.2) and need to add some GPS functionalites such as:
a. Latitude
b. Longitude
c. Satellite date/time (UTC)
d. Speed
e. Number of satellites locked
f. Heading
I found a way to retrieve the Latitude, Longitude, Speed and Heading. Is that possible to get the Satelite date/time and Number os satelites locked?
Thansks
Ximu
02-18-2010 04:22 PM
You can call getExtraInfo on a location object to get the additional data you're looking for -
In particular, the $GPGGA string mentioned in the javadoc contains the satellite date/time and number of satellites locked.
02-18-2010 04:22 PM
Number of satellites locked is actually an integer stored in the Location object. I can't find out how to access it, but it's there.
As for date/time, the only way I could find to get it is the following:
// Date/Time ----------------------------------------
Calendar calender = Calendar.getInstance();
String dateTime = (calender.getTime ()).toString () + " ";
//Format = "Wed Feb 03 20:45:31 GMT 2010"
You can use the String.substring method to extract the specific pieces and store them. For example:
//Time - Hours
GPSBytes [13] = (byte) (Integer.parseInt (dateTime.substring (11,13)));
There's also Location.getTimestamp, but it returns the number of milliseconds since January first, 12:00:00 am, 1970. Accurate, but difficult to work with.
Note: Java doesn't have a switch/case that uses Strings, so you'll have to manually create an if statement for each month to enumerate them.
Hope that helps,
~Dom