Code example for AudioRecord

Methods: getRecordingStategetStatestop

0
	 * If stopping fails then sets the state to ERROR.</p> 
	 */ 
	public void stop() { 
		// We check the underlying AudioRecord state trying to avoid IllegalStateException. 
		// If it still occurs then we catch it. 
		if (mRecorder.getState() == AudioRecord.STATE_INITIALIZED &&
				mRecorder.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING) {
			try { 
				mRecorder.stop();
				setState(State.STOPPED);
			} catch (IllegalStateException e) {
				Log.e(LOG_TAG, "native stop() called in illegal state: " + e.getMessage());
				setState(State.ERROR);
			} 
		} else { 
			Log.e(LOG_TAG, "stop() called in illegal state");
			setState(State.ERROR);
		} 
	}