title: how to know my app's AudioRecord permission is disallowed or not
body: <p>My app's record audio permission was disallowed by user.The problem is some android os devices `audio_recorder.getRecordingState()` always returns `AudioRecord.RECORDSTATE_RECORDING`.It's not a right result.</p>
  
  <p>How can I know the record audio permission is available ? </p>
  
  <pre><code>public final class MtAudioRecord {
  
  private static final String TAG = "audioRecord";
  private static MtAudioRecord instance = null;
  public static int SAMPLE_RATE = 44100;// default 44100
  public static final int CHANNEL_CONFIG = AudioFormat.CHANNEL_IN_MONO;
  public static final int AUDIO_FORMAT = AudioFormat.ENCODING_PCM_16BIT;
  public static final int AUDIO_SOURCE = MediaRecorder.AudioSource.MIC;
  
  private AudioRecord mAudioRecord;
  private final int minBufferSize;
  private boolean isRecording = true;
  private static short[] audioData = null;
  
  public static final MtAudioRecord getInstance() {
      if (null == instance) {
          instance = new MtAudioRecord();
      }
      return instance;
  }
  
  public MtAudioRecord() {
      minBufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIG, AUDIO_FORMAT);
      if (minBufferSize == AudioRecord.ERROR_BAD_VALUE) {
      } else if (minBufferSize == AudioRecord.ERROR) {
      } else {
          mAudioRecord =
              new AudioRecord(AudioSource.MIC, SAMPLE_RATE, AudioFormat.CHANNEL_IN_MONO,
                  AudioFormat.ENCODING_PCM_16BIT, minBufferSize);
      }
      audioData = new short[minBufferSize];
  }
  
  public synchronized void start() {
  
      new Thread(new Runnable() {
  
          @Override
          public void run() {
              if(null != mAudioRecord){
                  if (mAudioRecord.getRecordingState() != AudioRecord.STATE_INITIALIZED) {
                      Log.e(TAG, "Mic didn't successfully initialized");
                      return;
                  }
                  mAudioRecord.startRecording();
                  Log.e(TAG, "recording state = " + mAudioRecord.getRecordingState());
                  if (mAudioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
                      Log.e(TAG, "Mic is in use and can't be accessed");
                      return;
                  }
                  isRecording = true;
                  while (isRecording &amp;&amp; null != mAudioRecord) {
                      if (null == audioData) {
                          audioData = new short[minBufferSize];
                      }
                      final int read_distance = mAudioRecord.read(audioData, 0, minBufferSize);
                      if (read_distance == AudioRecord.ERROR_INVALID_OPERATION || read_distance == AudioRecord.ERROR || read_distance == AudioRecord.ERROR_BAD_VALUE) {
                          isRecording = false;
                          break;
                      }
                  }
                  if (mAudioRecord != null) {
                      mAudioRecord.stop();
                      mAudioRecord.release();
                      mAudioRecord = null;
                  }
              }
          }
      }).start();
  }
  
  public synchronized void stop() {
      isRecording = false;
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.RECORD_AUDIO"/&gt;
  </code></pre>