Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android detecting AudioRecord/ways to record audio without blocking other apps

Right now my application lets the user start recording audio and puts an ongoing notification that can pause/restart recording on press using android.media.AudioRecord. All was fine and dandy until I realized that this blocks any other App from using an AudioRecorder (ie google voice search).

Is there a way I can set up a broadcast reciever to detect a call for an AudioRecorder from another app and pause my recording. Alternatively, is there another way to record audio that wont interfere with other Apps that use audio?

Cheers!

like image 547
isep Avatar asked Nov 05 '22 23:11

isep


1 Answers

I have been looking into this very question for a while now. It seems that there is no clean way of achieving this as there is no broadcast that alerts when another app would like access to the mic.
The way that we have solved it (albeit not cleanly) is we poll what app is in the foreground and get its permissions; if that app has permission to use the mic, we terminate recording until there isn't an app in the foreground with the mic permission.

Although polling is a solution, I would be very interested if anyone has better!

like image 197
iamthearm Avatar answered Nov 11 '22 10:11

iamthearm