Android Programming: Looping Voice Recognition


I'm looking to make a custom Android app to help out a physically disabled person. I need to heavily rely on voice recognition. The idea would be:

  1. the app (via voice recognition) accepts his speech
  2. the app parses his speech and executes his commands ("email dad", "text fred", "what time is it?", etc, plus other things I'll be adding to control his tv, lights, etc)
  3. after execution, the app waits for his next command (loop back to #1)

I have #1 & #2 working fine, but I can't figure out a good method for #3. I can't leave Google's voice recognition view running indefinitely because it could be hours before the next command. But the 'trigger' does have to be based on sound/voice. Has to be completely hands free.

Ideally, the app would just listen for a sound, and if that sound is above a certain pre-programmed decibel level, I'd start voice recognition. Is it possible to constantly loop just listening for a noise, then react if it's 'so' loud?

Any ideas?


So the idea is that you want voice recognition to be ongoing. It is very hard to do that. But the way that I accomplished this is by using:

   try {
   }  catch (InterruptedException e) {
        // It depends on your app logic what to do with InterruptedException
        // You can process it or rethrow or restore interrupted flag

After the onReady (so if the user doesn't say something around 4.5 seconds it resets and at results. This worked great for me.