@@ -0,0 +1,2648 @@
+/*%0A * Copyright (c) 2016 Qiscus.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *    http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.qiscus.sdk.util;%0A%0Aimport android.media.MediaRecorder;%0Aimport android.os.Environment;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.Date;%0Aimport java.util.Locale;%0A%0A/**%0A * Created on : November 02, 2016%0A * Author     : zetbaitsu%0A * Name       : Zetra%0A * Email      : zetra@mail.ugm.ac.id%0A * GitHub     : https://github.com/zetbaitsu%0A * LinkedIn   : https://id.linkedin.com/in/zetbaitsu%0A */%0Apublic class QiscusAudioRecorder %7B%0A    private MediaRecorder recorder;%0A    private boolean recording;%0A    private String fileName;%0A%0A    public void startRecording() throws IOException %7B%0A        String timeStamp = new SimpleDateFormat(%22yyyyMMdd_HHmmss%22, Locale.US).format(new Date());%0A        String audioFileName = %22AUDIO_%22 + timeStamp + %22_%22;%0A        File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);%0A        String file = storageDir.getAbsolutePath();%0A        file += File.separator + audioFileName + %22.m4a%22;%0A        startRecording(file);%0A    %7D%0A%0A    private void startRecording(String fileName) throws IOException %7B%0A        if (!recording) %7B%0A            this.fileName = fileName;%0A            recording = true;%0A            recorder = new MediaRecorder();%0A            recorder.setAudioSource(MediaRecorder.AudioSource.MIC);%0A            recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);%0A            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);%0A            recorder.setOutputFile(fileName);%0A            recorder.prepare();%0A            recorder.start();%0A        %7D%0A    %7D%0A%0A    public File stopRecording() %7B%0A        cancelRecording();%0A        return new File(fileName);%0A    %7D%0A%0A    public void cancelRecording() %7B%0A        if (recording) %7B%0A            try %7B%0A                recorder.stop();%0A                recorder.release();%0A                recorder = null;%0A                recording = false;%0A            %7D catch (Exception ignored) %7B%0A%0A            %7D%0A        %7D%0A    %7D%0A%0A    public boolean isRecording() %7B%0A        return recording;%0A    %7D%0A%7D%0A

Add util class to record audio