The following code works fine:

if (ActivityCompat.checkSelfPermission(_activity, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) {
   _ar = new AudioRecord(MediaRecorder.AudioSource.MIC, iAudioSampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, N * 10);
}

The Android Studio always gives the warning "Missing permissions required by AudioRecord.AudioRecord: android.permission.RECORD_AUDIO" enter image description here

The AndroidManifest.xml already has the following:

<uses-permission android:name="android.permission.RECORD_AUDIO" />

If I click "Add Permission RECORD_AUDIO", Android adds another line of permission, so the AndroidManifest has two:

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

The warning still does not go away. Could anyone shed some light on this?

This is a library project.

enter image description here

1

There are 1 answers

0
Carlos C. On

I'm having the same issue with CameraX (1.2.0-alpha01) and decided to suppress the warning with @SuppressLint("MissingPermission") and still check/request my permissions at runtime, similar to this example by Google.