@Override
  public void onDestroy() {
    log.debug("Called onDestroy()");

    persistor.close();

    executorService.shutdown();

    super.onDestroy();
  }
 public void doSendStatus() {
   Intent intent = new Intent(IntentAPI.RETURN_STATUS);
   intent.putExtra(IntentAPI.FIELD_SAMPLING, isRecording);
   intent.putExtra(IntentAPI.FIELD_TRANSFERRING, transferManager.isTransferring());
   intent.putExtra(
       IntentAPI.FIELD_SAMPLES_STORED,
       persistor.hasSamples() | transferManager.hasStagedSamples());
   intent.putExtra(ExtendedIntentAPI.FIELD_STREAMING, isStreaming);
   intent.putExtra(IntentAPI.FIELD_HAR, isHAR);
   intent.putExtra(IntentAPI.FIELD_USER_ID, userId);
   sendBroadcast(intent);
 }
  private void doEnableRecording() {
    connectorThread.addConsumer(persistor);
    isRecording = true;

    final Tag tagStartRecording =
        new Tag(
            System.currentTimeMillis(), GlobalContext.getUserId(), IntentAPI.VALUE_START_RECORDING);

    persistor.push(tagStartRecording);

    // API EXTENSIONS are triggered on together with recording
    if (API_EXTENSIONS) {
      publisher.push(tagStartRecording);
      connectorThread.addConsumer(publisher);
      connectorThread.addConsumer(gpsCache);
    }
  }
  private void doDisableRecording() {
    connectorThread.removeConsumer(persistor);
    isRecording = false;

    final Tag stopRecordingTag =
        new Tag(
            System.currentTimeMillis(), GlobalContext.getUserId(), IntentAPI.VALUE_STOP_RECORDING);

    persistor.push(stopRecordingTag);

    // API EXTENSIONS are triggered on together with recording
    if (API_EXTENSIONS) {
      // Add "STOP RECORDING TAG" to publisher
      publisher.push(stopRecordingTag);
      connectorThread.removeConsumer(publisher);
      connectorThread.removeConsumer(gpsCache);
    }
  }
 private void doDeleteSamples() {
   persistor.deleteSamples();
   publisher.deleteSamples();
   transferManager.deleteStagedSamples();
 }