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
android android-intent service broadcastreceiver microphone
Josh
source share