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;
    } 

}
gnat
  • 6,213
  • 108
  • 53
  • 73
  • Can you post some code, showing how you setup your listener? Which APIs and OS versions are you using? How do you setup your location criteria? – Nate Nov 29 '12 at 12:44
  • I added the code. Let me know if I need to add any additional info. – RedDopamine Nov 29 '12 at 14:29

1 Answers1

2

You are setting your criteria to update every 300 seconds if locationInterval == 0 or at the default rate (once per second) otherwise. Is this really what you want? Where is locationInterval initialized? How does its value change as the program runs?

Richard
  • 8,920
  • 2
  • 18
  • 24
  • The locationinterval is initialized from another method which I did not include. I installed the same app in all the devices. Except for 2 devices the rest of them are getting updates at the interval value specified by locationInterval. – RedDopamine Nov 29 '12 at 18:57
  • It is difficult to comment further without seeing all the pertinent code. The behaviour you are reporting is explained by differing values of locationInterval when constructCriteria() is called. Have you tried logging that value to see what it actually is when setLocationListener() is called? – Richard Nov 29 '12 at 19:33
  • The value of the locationInterval was set to 250 seconds. When I logged it, that was what got printed. – RedDopamine Nov 29 '12 at 21:45