Microphone permission
Asked Answered
T

6

30

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?

Tran answered 18/7, 2014 at 5:31 Comment(9)
Can you share your code and error?Carhart
Have you used any kind of recording functionality in your app?Brookes
Is your app getting crashed on installation? If so, can we see your log cat?Yearwood
@PankajKumar I don't have an error, I was just wondering why my app requests the permission to use the microphone :)Tran
@Brookes The only thing I can think of is the cameraTran
Check this : developer.android.com/reference/android/…Yearwood
What is permission text?Carhart
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.Brookes
Have you used any library or dependency that may need to capturing audio ?Funches
W
48
<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>
Wira answered 18/7, 2014 at 5:39 Comment(1)
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.Ocker
B
12

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" />
Brookes answered 18/7, 2014 at 5:42 Comment(0)
I
12

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);

}
Imbibition answered 6/9, 2019 at 14:19 Comment(1)
The Java code is to put in which file?Section
F
9

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" />
Funches answered 16/12, 2016 at 10:44 Comment(0)
C
0

I can't believe how wrong everyone got your question. They all just mindlessly jumped on the runtime permissions train hoping to provide any answer.

The Microphone permission can be coming from a third party library. Doesn't have to be defined in your Manifest.

Here is what you do:

Option 1: Check the "Merged Manifest" in all your modules. This will aggregate all manifests and permissions in all libraries used in your app.

Option 2: The above is not searchable. Do this to quickly search for the troublesome permission among merged manifests:

  1. Change to "Project Files" view in Android studio
  2. Go to "build -> "outputs" -> "logs"
  3. Open "manifest-merger-report" file and you'll be able to quickly search for the troublesome permission. You will see which library uses it.

for more info:

https://stackoverflow.com/questions/35627210...

https://stackoverflow.com/questions/30546197...

It is an old question but I struggled with it at the end of 2021 and only found three stack overflow questions.

Crownwork answered 30/12, 2021 at 16:46 Comment(1)
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.Inapprehensive
P
0

you need to use 2 permission for audio manipulation, put this in AndroidManifest.xml outside application tag.

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
Peepul answered 17/7 at 14:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.