I am currently working on an Android project on which we have a audio recorder module.
I am using MediaRecorder and it's working as expected except in some annoying situations :
- When a notification sound is triggered by Android, the MediaRecorder stops
- When receiving a phone call and even if refusing the call, the MediaRecorder stops
- When the screen goes off
mRecorder = new MediaRecorder ();
mRecorder.setAudioSource (MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat (MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile (mFileName3GP);
mRecorder.setAudioEncoder (MediaRecorder.AudioEncoder.AAC);
mRecorder.setAudioEncodingBitRate (96000);
mRecorder.setAudioSamplingRate (48000);
mRecorder.start ();
I obviously doesn't want the audio recording to still be running during a call but on other situations I'd like my app to still perform the recording normally.
I didn't find anything pointing towards a solution. However, I am thinking about wakelocks (for screen off) and AudioFocus (for notifications and incoming calls).
Any advice ?
Thanks, ant1