Examples of BlackBerryLocation


Examples of net.rim.device.api.gps.BlackBerryLocation

        new Thread () {
      public void run() {
        try
        {
          //get current location - 4 tries or bust - in case of invalid fix
              BlackBerryLocation myLocation = getGeolocation(4);
         
              // Show location.
              if (myLocation != null){
                currSelection = new MapPoint(myLocation.getQualifiedCoordinates());
                PeerPoint point = new PeerPoint(myLocation.getQualifiedCoordinates().getLatitude(), myLocation.getQualifiedCoordinates().getLongitude());
                point.setAccuracy(MathUtilities.round(myLocation.getQualifiedCoordinates().getHorizontalAccuracy()));
               
                //auto zoom to point
                map.getAction().setCenterAndZoom(point);
               
                //add the point with accuracy circle
View Full Code Here

Examples of net.rim.device.api.gps.BlackBerryLocation

    private BlackBerryLocation getGeolocation(int numTries){
      if (numTries == 0) return null;
     
      //get current location
        BlackBerryCriteria myCriteria = new BlackBerryCriteria(LocationInfo.GEOLOCATION_MODE);
        BlackBerryLocation myLocation = null;
        try {
      BlackBerryLocationProvider myProvider = (BlackBerryLocationProvider)
      LocationProvider.getInstance(myCriteria);
      myLocation = (BlackBerryLocation)myProvider.getLocation(-1);
      if (myLocation.isValid()) return myLocation;
      else return getGeolocation(numTries-1);
    } catch (LocationException e) {
      //possible no towers found
      e.printStackTrace();
    } catch (InterruptedException e) {
View Full Code Here

Examples of net.rim.device.api.gps.BlackBerryLocation

  public void locationUpdated(LocationProvider provider, Location location) {
    if(provider != this.locationProviderReference){ // if this is an update from an old location provider that is in the process of being stopped, ignore the update.
      return;
    }
   
    BlackBerryLocation bbLocation = (BlackBerryLocation) location;
   
   
    if(bbLocation!=null && bbLocation.isValid() && (bbLocation.getQualifiedCoordinates().getLatitude()!=0 && bbLocation.getQualifiedCoordinates().getLongitude()!=0)){ 
      log("Tracking: Acquired valid location - " + location.getQualifiedCoordinates().getLatitude() + ", " + location.getQualifiedCoordinates().getLongitude());
      this.location = (BlackBerryLocation) location;       
      /**
       * retryAttempt should not be reset in MODE_OPTIMAL when currentOptimalModeIsGeolocation
       * because last GPS fix might have failed and this is only a fall back to Geolocation that has passed.
       * We still need to preserve the retryAttempt until a GPS fix works in MODE_OPTIMAL. Otherwise
       * we will simply waste battery by trying GPS fixes too frequently when it is not available.
       */
      if( mode!=MODE_OPTIMAL || (mode==MODE_OPTIMAL && !currentOptimalModeIsGeolocation) ){
        retryAttempt = 0;
        log("Tracking: retryAttempt reset to 0");
      }
     
      /** Update lastValidFixTime */       
      lastValidFixTime = System.currentTimeMillis();
      log("Tracking: lastValidFixTime updated.");
     
      /** Trigger events via SimpleLocationListener */
      if(bbLocation.getGPSMode()==GPSInfo.GPS_MODE_AUTONOMOUS){
        simpleLocationListener.locationEvent(SimpleLocationListener.EVENT_GPS_LOCATION, bbLocation);
        log("Tracking: Location delivered to SimpleLocationListener as EVENT_GPS_LOCATION");
      }       

      else if(bbLocation.getGPSMode()==GPSInfo.GPS_MODE_CELLSITE){
        simpleLocationListener.locationEvent(SimpleLocationListener.EVENT_CELL_GEOLOCATION, bbLocation);
        log("Tracking: Location delivered to SimpleLocationListener as EVENT_CELL_GEOLOCATION");
      }

     
View Full Code Here

Examples of net.rim.device.api.gps.BlackBerryLocation

  public void locationUpdated(LocationProvider provider, Location location) {
    if(provider != this.locationProviderReference){ // if this is an update from an old location provider that is in the process of being stopped, ignore the update.
      return;
    }
   
    BlackBerryLocation bbLocation = (BlackBerryLocation) location;
   
   
    if(bbLocation!=null && bbLocation.isValid() && (bbLocation.getQualifiedCoordinates().getLatitude()!=0 && bbLocation.getQualifiedCoordinates().getLongitude()!=0)){ 
      log("Tracking: Acquired valid location - " + location.getQualifiedCoordinates().getLatitude() + ", " + location.getQualifiedCoordinates().getLongitude());
      this.location = (BlackBerryLocation) location;       
      /**
       * retryAttempt should not be reset in MODE_OPTIMAL when currentOptimalModeIsGeolocation
       * because last GPS fix might have failed and this is only a fall back to Geolocation that has passed.
       * We still need to preserve the retryAttempt until a GPS fix works in MODE_OPTIMAL. Otherwise
       * we will simply waste battery by trying GPS fixes too frequently when it is not available.
       */
      if( mode!=MODE_OPTIMAL || (mode==MODE_OPTIMAL && !currentOptimalModeIsGeolocation) ){
        retryAttempt = 0;
        log("Tracking: retryAttempt reset to 0");
      }
     
      /** Update lastValidFixTime */       
      lastValidFixTime = System.currentTimeMillis();
      log("Tracking: lastValidFixTime updated.");
     
      /** Trigger events via SimpleLocationListener */
      if(bbLocation.getGPSMode()==GPSInfo.GPS_MODE_AUTONOMOUS){
        simpleLocationListener.locationEvent(SimpleLocationListener.EVENT_GPS_LOCATION, bbLocation);
        log("Tracking: Location delivered to SimpleLocationListener as EVENT_GPS_LOCATION");
      }       
      //#ifdef BlackBerrySDK5.0.0
      else if(bbLocation.getGPSMode()==GPSInfo.GPS_MODE_CELLSITE){
        simpleLocationListener.locationEvent(SimpleLocationListener.EVENT_CELL_GEOLOCATION, bbLocation);
        log("Tracking: Location delivered to SimpleLocationListener as EVENT_CELL_GEOLOCATION");
      }
      //#endif 
     
      //#ifdef BlackBerrySDK6.0.0
      else if(bbLocation.getGPSMode()==LocationInfo.GEOLOCATION_MODE_CELL){
        simpleLocationListener.locationEvent(SimpleLocationListener.EVENT_CELL_GEOLOCATION, bbLocation);
        log("Tracking: Location delivered to SimpleLocationListener as EVENT_CELL_GEOLOCATION");
      } else if(bbLocation.getGPSMode()==LocationInfo.GEOLOCATION_MODE_WLAN){
        simpleLocationListener.locationEvent(SimpleLocationListener.EVENT_WLAN_GEOLOCATION, bbLocation);
        log("Tracking: Location delivered to SimpleLocationListener as EVENT_WLAN_GEOLOCATION");
      }                       
      //#endif
      else{ // This should not occur
View Full Code Here

Examples of net.rim.device.api.gps.BlackBerryLocation

  public void locationUpdated(LocationProvider provider, Location location) {
    if(provider != this.locationProviderReference){ // if this is an update from an old location provider that is in the process of being stopped, ignore the update.
      return;
    }
   
    BlackBerryLocation bbLocation = (BlackBerryLocation) location;
   
   
    if(bbLocation!=null && bbLocation.isValid() && (bbLocation.getQualifiedCoordinates().getLatitude()!=0 && bbLocation.getQualifiedCoordinates().getLongitude()!=0)){ 
      log("Tracking: Acquired valid location - " + location.getQualifiedCoordinates().getLatitude() + ", " + location.getQualifiedCoordinates().getLongitude());
      this.location = (BlackBerryLocation) location;       
      /**
       * retryAttempt should not be reset in MODE_OPTIMAL when currentOptimalModeIsGeolocation
       * because last GPS fix might have failed and this is only a fall back to Geolocation that has passed.
       * We still need to preserve the retryAttempt until a GPS fix works in MODE_OPTIMAL. Otherwise
       * we will simply waste battery by trying GPS fixes too frequently when it is not available.
       */
      if( mode!=MODE_OPTIMAL || (mode==MODE_OPTIMAL && !currentOptimalModeIsGeolocation) ){
        retryAttempt = 0;
        log("Tracking: retryAttempt reset to 0");
      }
     
      /** Update lastValidFixTime */       
      lastValidFixTime = System.currentTimeMillis();
      log("Tracking: lastValidFixTime updated.");
     
      /** Trigger events via SimpleLocationListener */
      if(bbLocation.getGPSMode()==GPSInfo.GPS_MODE_AUTONOMOUS){
        simpleLocationListener.locationEvent(SimpleLocationListener.EVENT_GPS_LOCATION, bbLocation);
        log("Tracking: Location delivered to SimpleLocationListener as EVENT_GPS_LOCATION");
      }       
      //#ifdef BlackBerrySDK5.0.0
      else if(bbLocation.getGPSMode()==GPSInfo.GPS_MODE_CELLSITE){
        simpleLocationListener.locationEvent(SimpleLocationListener.EVENT_CELL_GEOLOCATION, bbLocation);
        log("Tracking: Location delivered to SimpleLocationListener as EVENT_CELL_GEOLOCATION");
      }
      //#endif 
     
      //#ifdef BlackBerrySDK6.0.0
      else if(bbLocation.getGPSMode()==LocationInfo.GEOLOCATION_MODE_CELL){
        simpleLocationListener.locationEvent(SimpleLocationListener.EVENT_CELL_GEOLOCATION, bbLocation);
        log("Tracking: Location delivered to SimpleLocationListener as EVENT_CELL_GEOLOCATION");
      } else if(bbLocation.getGPSMode()==LocationInfo.GEOLOCATION_MODE_WLAN){
        simpleLocationListener.locationEvent(SimpleLocationListener.EVENT_WLAN_GEOLOCATION, bbLocation);
        log("Tracking: Location delivered to SimpleLocationListener as EVENT_WLAN_GEOLOCATION");
      }                       
      //#endif
      else{ // This should not occur
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.