How to release a microphone resource when it needs another Android application?

I implemented an Android background service (based on Pocket Sphinx), which constantly listens, detects and fixes certain keywords when the phone screen is on, and then reacts accordingly (for a domino project). However, my application should always have a lower priority, and I want it to free up microphone resources when some other application should use it. Are there any system intentions or system broadcasts that I can get when the application uses - use a microphone (so that my service can release it)? Or is there a better approach or best practice?

This is a log with errors that I want to avoid when another application wants to access the microphone:

AudioFocus requestAudioFocus() from android.media.AudioManager@419c3908com.google.android.voicesearc h.a.h@419c67b8 I/MicrophoneInputStream(32360): mic_starting com.google.android.speech.audio.w@41989a30 D/AudioHardwareALSA(277): openInputStream: devices 0x400000 format 0x1 channels 16 sampleRate 16000 E/AudioHardwareALSA(277): error:Input stream already opened for recording E/AudioRecord(32360): Could not get audio input for record source 6 E/AudioRecord-JNI(32360): Error creating AudioRecord instance: initialization check failed. E/AudioRecord-Java(32360): [ android.media.AudioRecord ] Error code -20 when initializing native AudioRecord object. E/MicrophoneInputStream(32360): Failed to initialize AudioRecord 
+7
android android-intent service broadcastreceiver microphone
source share

No one has answered this question yet.

See related questions:

3295
Why is the Android emulator so slow? How can we speed up Android emulator development?
1270
How to transfer data between actions in an Android application?
831
How to control startActivityForResult on Android?
809
How to send an object from one Android activity to another using intentions?
672
How to get additional data from intent on Android?
583
How to transfer an object from one action to another on Android
409
Launch an app from another Android app
14
<AudioRecord> "Failed to get audio input for recording source 1"
one
Released microphone when you need to use another application
0
Android AudioRecord is there a release method when I no longer have a link?

All Articles