0

I'm trying to build an app that sparks into action following a pre-defined voice command from me, just like "OK Google". I want my device to launch a voice recognition intent just as soon as I give my "OK Google" type of message. already know how to launch such an intent:

if (isConnected()) {
            Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
            intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
            intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 4);
            intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
            startActivityForResult(intent, REQUEST_CODE);
        } else {
            Toast.makeText(getApplicationContext(), "Plese Connect to Internet", Toast.LENGTH_LONG).show();
        }

However, right now, I'm only able to start this intent following a tap on a button. I want to be able to launch it without interacting with the UI. It may be possible to launch intent after intent in expectation of a vocal command, but it's not the desired approach.

Does anyone know how to do this?

logcat
  • 283
  • 2
  • 12
  • Possible duplicate of [How to Intercept Google Now Voice Commands in Android](http://stackoverflow.com/questions/22185345/how-to-intercept-google-now-voice-commands-in-android) – Nikolay Shmyrev Nov 02 '15 at 00:26
  • Also http://stackoverflow.com/questions/3148603/continuous-speech-recognition-android – Nikolay Shmyrev Nov 02 '15 at 00:27

0 Answers0