Exemplo n.º 1
0
  @Override
  public void start() {
    super.start();
    setRunning(true);

    Log.d(TAG, "Starting Location sensor");

    // Use any provider (LOCATION, Network or Passive)
    addLocationListenerWithAllProviders();

    IntentFilter intentFilter = new IntentFilter(LOCATION_UPDATE_ACTION);
    getContext().registerReceiver(locationReceiver, intentFilter);

    Log.d(TAG, "Starting Location sensor [done]");

    Sensor.setSensorStatus(Sensor.SENSOR_LOCATION, Sensor.SENSOR_ON);
    refreshStatus();

    if (stpe == null) {
      stpe = new ScheduledThreadPoolExecutor(1);
      stpe.scheduleAtFixedRate(controller, 0, Utilities.LOCATION_CHECK_TIME, TimeUnit.MILLISECONDS);
      /*stpe.scheduleAtFixedRate(controller, MAX_TIME_WITHOUT_NEW_LOCATION,
      MAX_TIME_WITHOUT_NEW_LOCATION, TimeUnit.MILLISECONDS);*/
    }
  }