Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to detect which application is using the microphone.

Suppose two applications have access to the microphone. For an application to use the microphone, it should have android.permission.RECORD_AUDIO.

With the lsof command, we can detect the microphone is being used, but not the application name that is using it. So we can list down all the currently running applications, then we can check which application has android.permission.RECORD_AUDIO permission, but here is the problem:

Suppose we have two applications named "A" and "B". A can only record voice while B has an option to record voice and maintain network status. As both can record voice, both will have android.permission.RECORD_AUDIO permission. So we can know that both A and B can use the mic, but at present, which one is using the mic? How can I avoid such confusion?
Posted
Comments
Ed Nutting 25-Aug-12 15:21pm    
If there is no command to tell you which application is using the mic, then I highly doubt it is possible to do. It is probably a good thing that you can't spy on other applications - security wise not being able to do this sounds sensible. Instead, you could ask the user to close any applications that may be using the mic and include in the message the detected list of possible currently running applications that they should close. I assume your intent was to force close the application using the mic? Very bad idea...you could easily cause file corruption etc. on the user's device and/or cause them huge problems e.g. if they were in the middle of an important Skype call I don't think they would appreciate your app just suddenly ending that. Always best to let the user handle which they want to use as they are the USEr. If they choose not to close other applications then that's their choice.

Ed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900