2

I have a 3 GSM phones and a 3 verizon (CDMA) phones. I have a BB application in which the location listener is set to a 5 minute interval.

For 2 of the verizon phones the application's location update method gets called frequently. For the rest, the location listener gets called at a regular 5 minute interval.

What could be causing this difference in behavior?

public synchronized void locationUpdated(LocationProvider locationProvider, Location location) {
        if (enabled) {

            if (blackberryProvider != null) {
                try {                       
                    constructCriteria(GPSInfo.GPS_MODE_CELLSITE);
                    gpsUpdate();
                } catch (LocationException e) {
                   log stuff//  
                }
            }
        }
    }


    private void gpsUpdate() throws LocationException, InterruptedException {
        try {
            String gpsMode = null;
        if (bbCriteria.getMode() == GPSInfo.GPS_MODE_CELLSITE) {
                gpsMode = "cellsiteMode";
            }


            if (gpsMode == "cellsiteMode" && gpsMode.length() > 0 && bbProvider != null) {
                // variable declaration

                try {
                    bbLocation = (BlackBerryLocation) bbProvider.getLocation(10);
                } catch (LocationException e) {

                    bbLocation = null;
                }

                if (bbLocation != null) {
                    // do stuff
                    // store location in the database   


                        }

                    }

                }

            }
        }
    }





private void constructCriteria(final int mode) {
    blackberryCriteria = null;
    blackberryProvider = null;
    blackberryCriteria = new BlackBerryCriteria();
    blackberryCriteria.setSatelliteInfoRequired(true, false);



     if (mode == GPSInfo.GPS_MODE_CELLSITE) {
        setCriteraForCellSite();
    }
    try {
        blackberryProvider = (BlackBerryLocationProvider) LocationProvider.getInstance(blackberryCriteria);

        if (iLocationListner == null) {
            iLocationListner = new ILocationListner();
            blackberryProvider.setLocationListener(iLocationListner, locationInterval == 0 ? 300 : locationInterval, -1, -1);
        } else {
            blackberryProvider.setLocationListener(iLocationListner, locationInterval == 0 ? 300 : locationInterval, -1, -1);
        }
    } catch (LocationException lex) {
        Logger.log("LocationEventSource constructor", lex);
        return;
    } 

}
4

1 回答 1

2

您将标准设置为每 300 秒更新一次,locationInterval == 0否则以默认速率(每秒一次)更新。这真的是你想要的吗?locationInterval 在哪里初始化?随着程序运行,它的值如何变化?

于 2012-11-29T18:11:12.637 回答