code: public void stopRecording(){
          if (currentAudioState.get()== PAUSED_STATE || currentAudioState.get()==RECORDING_STATE){
              currentAudioState.getAndSet(STOPPED_STATE);
              onTimeCompletedTimer.cancel();
              onTimeCompletedTimer=null;
              onTimeCompletionTimerTask=null;
          }
          else{
              Log.w(TAG,"Audio recording is not in a paused or recording state.");
          }
          currentAudioRecordingThread=null;//The existing thread will die out on its own, but not before attempting to convert the file into WAV format.
      }
docs: Stops the audio recording if it is in a paused or recording state. Does nothing if the recorder is already stopped.
  @throws IllegalStateException If the recorder is not in a paused, recording, or stopped state.