@Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        audioRecorder = new AudioRecorder();
        handler = new AudioRecordingDbmHandler();
        audioRecorder.recordingCallback(handler);
        audioVisualization.linkTo(handler);
        btnRecord.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (audioRecorder.isRecording()) {
                    audioRecorder.finishRecord();
                    btnRecord.setText(R.string.start_recording);
                    handler.stop();
                } else {
                    btnRecord.setText(R.string.stop_recording);
                    audioRecorder.startRecord();
                }
            }
        });
    }
Fragment with visualization of audio recording.
app/src/main/java/com/cleveroad/example/AudioRecordingFragment.java