BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 07-23-2008, 12:16 PM   #1 (permalink)
Knows Where the Search Button Is
Join Date: Oct 2005
Model: 7250
Carrier: ATT
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Bluetooth GPS hoses up on OS 4.2.X

Please Login to Remove!

I've pasted a simple application that stops getting fixes from a bluetooth GPS unit when it goes out of range or turned off... and then is turned back on/comes back in range. This is a one-shot TimerTask-based LocationProvider.getLocation that will return timeouts forever after the condition occurs. Pearl 8100/Globalsat BT-368i with OS 4.2.1. I have tested this with OS 4.5.0 (beta) and it DOES work there, but isn't a workable solution to require all my target customers to install a beta OS. Should be a simple test, could anyone spend 5 minutes and try this app out or lend some advice? Thanks!

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

import javax.microedition.location.*;
import java.util.*;

public class GPSDemo extends UiApplication 
    private static int _interval = 30; 
    private static int _cnt = 0;
    private EditField _status;
    private Timer timer = null;
    private final class GPSDemoScreen extends MainScreen
        protected void makeMenu(Menu menu, int instance)
            menu.add( _close );    
            super.makeMenu(menu, instance);
        public boolean onClose()
            if (timer != null)
            return super.onClose();
    public static void main(String[] args)
        new GPSDemo().enterEventDispatcher();

    public GPSDemo()
        GPSDemoScreen screen = new GPSDemoScreen();
        screen.setTitle(new LabelField("GPS", LabelField.USE_ALL_WIDTH));      
        _status = new EditField();
        timer = new Timer();
        timer.scheduleAtFixedRate(new GPSTask(),5000,60000);
    private final class GPSTask extends TimerTask
        public void run()
            LocationProvider lp = null;
            try {
                Criteria cr = new Criteria();
                lp = LocationProvider.getInstance(cr);
                Location l = lp.getLocation(30);
                if (l.isValid()) {
                    Coordinates c = l.getQualifiedCoordinates();
                    if ( c != null ) {
                        updateLocationScreen("Got a fix: " + _cnt);                        
                    } else {
                        updateLocationScreen("Coords was null");
                } else {
                    updateLocationScreen("location not valid");
            catch (Exception e) {
                updateLocationScreen("Failed: " + e.getMessage());
            if (lp != null) {
                lp.reset(); // Not sure if this is smart
                lp = null;

    private void updateLocationScreen(final String msg)
        invokeLater(new Runnable() {
            public void run()
                short[] explodeAudio =
                        300, 50, 500, 50, 300, 50, 500, 50, 300, 50
                if (Alert.isBuzzerSupported())
                    Alert.startBuzzer(explodeAudio, 100);
                else if (Alert.isAudioSupported())

    private MenuItem _close = new MenuItem("Close", 0, 10) {
        public void run()
    private MenuItem _background = new MenuItem("Background", 1, 10) {
        public void run()
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Genuine WESCO N6K universal joint cross 2.475" unknown appl. vintage driveline
Genuine WESCO N6K universal joint cross 2.475Vintage Letterpress Print Type Ornament Apple for Teacher Adcut
Vintage Letterpress Print Type Ornament Apple for Teacher Adcut pictureVintage Letterpress Print Type Ornament "An Apple A Day Bugs The A.M.A." Adcut
Vintage Letterpress Print Type Ornament Vintage Letterpress Print Type Ornament Apple Missing One Bite Adcut
Vintage Letterpress Print Type Ornament Apple Missing One Bite Adcut pictureVINTAGE APPLE EXTENDED KEYBOARD II

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.