content: package cafe.adriel.androidaudiorecorder.example;
  
  import android.Manifest;
  import android.content.Intent;
  import android.graphics.drawable.ColorDrawable;
  import android.os.Bundle;
  import android.os.Environment;
  import android.support.v4.content.ContextCompat;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.Toast;
  
  import cafe.adriel.androidaudiorecorder.AndroidAudioRecorder;
  import cafe.adriel.androidaudiorecorder.model.AudioChannel;
  import cafe.adriel.androidaudiorecorder.model.AudioSampleRate;
  import cafe.adriel.androidaudiorecorder.model.AudioSource;
  
  public class MainActivity extends AppCompatActivity {
      private static final int REQUEST_RECORD_AUDIO = 0;
      private static final String AUDIO_FILE_PATH =
              Environment.getExternalStorageDirectory().getPath() + "/recorded_audio.wav";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          if (getSupportActionBar() != null) {
              getSupportActionBar().setBackgroundDrawable(
                      new ColorDrawable(ContextCompat.getColor(this, R.color.colorPrimaryDark)));
          }
  
          Util.requestPermission(this, Manifest.permission.RECORD_AUDIO);
          Util.requestPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
      }
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          if (requestCode == REQUEST_RECORD_AUDIO) {
              if (resultCode == RESULT_OK) {
                  Toast.makeText(this, "Audio recorded successfully!", Toast.LENGTH_SHORT).show();
              } else if (resultCode == RESULT_CANCELED) {
                  Toast.makeText(this, "Audio was not recorded", Toast.LENGTH_SHORT).show();
              }
          }
      }
  
      public void recordAudio(View v) {
          AndroidAudioRecorder.with(this)
                  // Required
                  .setFilePath(AUDIO_FILE_PATH)
                  .setColor(ContextCompat.getColor(this, R.color.recorder_bg))
                  .setRequestCode(REQUEST_RECORD_AUDIO)
  
                  // Optional
                  .setSource(AudioSource.MIC)
                  .setChannel(AudioChannel.STEREO)
                  .setSampleRate(AudioSampleRate.HZ_48000)
                  .setAutoStart(false)
                  .setKeepDisplayOn(true)
  
                  // Start recording
                  .record();
      }
  
  }