Microphone permission

57,431

Solution 1

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

outside the application block actually solved it!

...
    </application>


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

Solution 2

If you are using any kind of audio recording functionality in your application then you are supposed to provide RECORD_AUDIO permission in your manifest file as below:

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

Solution 3

in your manifest use this

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

Then to request the permission do this:

if (ContextCompat.checkSelfPermission(getActivity(),
    Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {

ActivityCompat.requestPermissions(getActivity(),
        new String[]{Manifest.permission.RECORD_AUDIO},
        REQUEST_MICROPHONE);

}

Solution 4

Since Android 6.0 Marshmallow, application will not be granted any permission at installation time. Instead, application has to ask user for a permission one-by-one at runtime. Please note that permission request dialog shown above will not launch automatically. Developer has to call for it manually. In the case that developer try to call some function that requires a permission which user has not granted yet, the function will suddenly throw an Exception which will lead to the application crashing.

also add this to manifest:

<uses-permission android:name="android.permission.RECORD_AUDIO" />
Share:
57,431

Related videos on Youtube

deimos1988
Author by

deimos1988

Updated on December 31, 2021

Comments

  • deimos1988
    deimos1988 over 2 years

    When installing the app I programmed, it requires the permission "to use the microphone". I don't however specifically ask for it in the manifest, what I have is the camera permission.

    Is that where the microphone-permission is coming from?

    • Pankaj Kumar
      Pankaj Kumar almost 10 years
      Can you share your code and error?
    • GrIsHu
      GrIsHu almost 10 years
      Have you used any kind of recording functionality in your app?
    • VVB
      VVB almost 10 years
      Is your app getting crashed on installation? If so, can we see your log cat?
    • deimos1988
      deimos1988 almost 10 years
      @PankajKumar I don't have an error, I was just wondering why my app requests the permission to use the microphone :)
    • deimos1988
      deimos1988 almost 10 years
      @GrIsHu The only thing I can think of is the camera
    • VVB
      VVB almost 10 years
    • Pankaj Kumar
      Pankaj Kumar almost 10 years
      What is permission text?
    • GrIsHu
      GrIsHu almost 10 years
      If you are using camera then you only need camera permission. If you are getting any kind of errors then please add it in your question.
    • Rez
      Rez over 7 years
      Have you used any library or dependency that may need to capturing audio ?
  • Sara
    Sara over 5 years
    The question is why the permission shows up in the App Permissions if not explicitly requested (and required). I have the same issue, not need or ever set the Microphone permission in manifest, but my app settings shows as my app needs the Microphone permission.
  • Thanh Trung
    Thanh Trung over 2 years
    The Java code is to put in which file?
  • Adam R. Turner
    Adam R. Turner over 2 years
    It's not really that. It's that permissions for android changed wildly over the last few years. It used to be a lot more simple than it is now, that's why the old answers look dumb now.