I am trying to determine when any android application instead of only on incoming or outgoing calls, is requesting the use of the microphone. Is there a way to do it programmatically?
Asked
Active
Viewed 238 times
2 Answers
1
Yes, try to use microphone from any of Android built in audio recording classes (e.g. MediaRecorded, AudioRecord
) and you will get an Exception raised if someone else is using microphone at the same time (exactly as any resource becomes unavailable if you do not release it in onPause
/onDestroy
)

Radu Ionescu
- 3,462
- 5
- 24
- 43
-
So basically I have a voice recognition application which uses the microphone from any screen. And microphone does not work when someone either calls me or viber or what's up or whatever application that is. Thats why I want to stop my recognition when an app asks for the microphone – Stefanos Konstantinou Mar 16 '16 at 17:26
-
Since you have acquired the microphone before, the other apps can not use it. You can use a technique similar to [camera new picture receiver](http://stackoverflow.com/questions/20136577/display-a-message-when-the-default-camera-app-takes-a-picture), but I could not find the appropriate filter after searching for it. It could be there is no such intent filter for audio capture. – Radu Ionescu Mar 16 '16 at 17:38
-
Well yeah kind of. I am using a phone call receiver and an SMS Broadcast Receiver as well. So yeah probably something like a receiver but on request for record audio. Thanks anyway man – Stefanos Konstantinou Mar 16 '16 at 17:45
0
The permission you want to ask for is RECORD_AUDIO (http://developer.android.com/guide/topics/security/permissions.html)
Getting the permission of installed apps is described in How to get manifest permissions of any installed Android app.
-
So this means using the intent and then comparing the requested permissions to see if it matches Record_Audio permission? – Stefanos Konstantinou Mar 16 '16 at 17:16