title: Unable to request RECORD_AUDIO permission in Android
body: <p>I am developing an Android application that has its own video recorder feature. For that I need to request RECORD_AUDIO permission from the user. But when I request the permission, it is not showing the prompt to get the permission from the user.</p>
  
  <p>This is my function that checks if the app needs to request permission and it does automatically if required.</p>
  
  <pre><code>private boolean isRecordAudioPermissionGranted()
     {
        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
           if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) ==
              PackageManager.PERMISSION_GRANTED) {
              // put your code for Version&gt;=Marshmallow
              return true;
           } else {
              if (shouldShowRequestPermissionRationale(Manifest.permission.RECORD_AUDIO)) {
                 Toast.makeText(this,
                    "App required access to audio", Toast.LENGTH_SHORT).show();
              }
              requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO
              },AUDIO_RECORD_REQUEST_CODE);
              return false;
           }
  
        } else {
           // put your code for Version &lt; Marshmallow
           return true;
        }
     }
  </code></pre>
  
  <p>In the onCreate of the Activity, I call the function like this.</p>
  
  <pre><code>if(!isRecordAudioPermissionGranted())
        {
           Toast.makeText(getApplicationContext(), "Need to request permission", Toast.LENGTH_SHORT).show();
        }
  else{
     Toast.makeText(getApplicationContext(), "No need to request permission", Toast.LENGTH_SHORT).show();
  }
  </code></pre>
  
  <p>The app is saying that it needs to request permission, but it is just not prompting the request permission dialog. What is wrong with my code?</p>
  
  <p>This are the permissions I added and use in the manifest file.</p>
  
  <pre><code> &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
     &lt;uses-permission android:name="android.permission.READ_PROFILE" /&gt;
     &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
     &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
     &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
     &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
     &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
     &lt;uses-permission android:name="android.permission.VIBRATE"/&gt;
  
  
     &lt;uses-permission android:name="android.permission.WAKE_LOCK"/&gt;
     &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
     &lt;uses-permission android:name="android.Manifest.permission.RECORD_AUDIO"/&gt;
  
     &lt;uses-feature android:name="android.hardware.camera"/&gt;
     &lt;uses-feature android:name="android.hardware.camera.autofocus"/&gt;
     &lt;uses-feature android:name="android.hardware.camera.front"/&gt;
     &lt;uses-feature android:name="android.hardware.camera.front.autofocus"/&gt;
  
     &lt;uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true"/&gt;
     &lt;uses-feature android:name="android.hardware.sensor.gyroscope" android:required="true"/&gt;
     &lt;uses-feature android:name="android.software.vr.mode" android:required="true"/&gt;
     &lt;uses-feature android:name="android.hardware.vr.high_performance" android:required="true"/&gt;
  </code></pre>