title: Criteria and GPS in SDK 5.0 and later
body: <p>I'm currently developing a BB application and I need to get my current position. </p>
  
  <p>In BB models with v5.0 it's ok, but in BB with v6.0 I always get the locationProvider as null. (The gps is turned on).</p>
  
  <p>Anyone has an idea that what could happen and how to solve it?</p>
  
  <p>The piece of code that I use is:</p>
  
  <pre><code>private boolean startLocationUpdate() {
      boolean retval = false;
  
      try {
          Criteria criteria = new Criteria();
          criteria.setCostAllowed(true);
          criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
  
          criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
          criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
  
          locationProvider = LocationProvider.getInstance(criteria);
  
          if (locationProvider == null) {
  
              Runnable showGpsUnsupportedDialog = new Runnable() {
                  public void run() {
  
                      Dialog.alert("GPS is not supported on this platform...");
                      // System.exit( 1 );
                  }
              };
  
              UiApplication.getUiApplication().invokeAndWait(
                      showGpsUnsupportedDialog); // Ask event-dispatcher
                                                  // thread to display dialog
                                                  // ASAP.
          } else {
  
              locationProvider.setLocationListener(
                      new LocationListenerImpl(), interval, 1, 1);
  
              retval = true;
          }
      } catch (LocationException le) {
          System.err
                  .println("Failed to instantiate the LocationProvider object, exiting...");
          System.err.println(le);
          System.exit(0);
      }
      return retval;
  }
  </code></pre>
  
  <p>Thanks!</p>