Not getting RecognizerIntent result codes

by pac » Fri, 23 Apr 2010 01:18:44 GMT


Sponsored Links
 I want to get the RecognizerIntent result codes such as
RESULT_SERVER_ERROR because I want to distinguish between the cases
where the speech wasn't understood or no matches were found and the
cases where recognition didn't occur because of connection or server
problems.

When onActivityResult() executes, however, the result code is either
RESULT_OK or 0.  I never catch any of the various RecognizerIntent
result codes.  What do I need to do?

Here's my code:

  private void startVoiceRecognitionActivity() {
        Intent intent= new
Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                        RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say something!");
        startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
    }

    protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
        if (requestCode == VOICE_RECOGNITION_REQUEST_CODE &&
resultCode == RESULT_OK) {
              // do stuff
        }
        else if (requestCode == VOICE_RECOGNITION_REQUEST_CODE &&
resultCode != RESULT_OK) {

                // Figure out the error
                String err = "";
                switch (resultCode) {
                case (RecognizerIntent.RESULT_AUDIO_ERROR):
                        err = "Audio error";
                break;
                case (RecognizerIntent.RESULT_CLIENT_ERROR):
                        err = "Client error";
                break;
                case (RecognizerIntent.RESULT_NETWORK_ERROR):
                        err = "Network error";
                break;
                case (RecognizerIntent.RESULT_NO_MATCH):
                        err = "No match";
                break;
                case (RecognizerIntent.RESULT_SERVER_ERROR):
                        err = "Server error";
                break;
                }
       }
        super.onActivityResult(requestCode, resultCode, data);
    }

--



Other Threads

1. ADP1 ONLY instructions for backup, installing from git, then back to backup

Thanks very much for that lbcoder! I had actually already compiled
(for the dream target) and was ready to try it out but really didn't
want to try without a backup, knowing that there were some things
(like proprietary kernel modules/drivers) that aren't freely
available.
In any case, thanks for these clear and concise instructions.
Cheers
Anton



-- 
echo '16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D4D465452snlbxq' | dc
This will help you for 99.9% of your problems ...

--~--~---------~--~----~------------~-------~--~----~

2. Cupcake Android Dev Phone 1

Does anybody know if "Cupcake" will also be available for the "Android
Dev Phone 1"? And are there any details available?

I assume T-Mobile will update only phones of their customers.

Best regards

Mirko

--~--~---------~--~----~------------~-------~--~----~

3. Eclipse Plug-in Site down?

4. problems when setting / removing color filter to image views

5. Touch mode again (CRUD application context).

6. G1 OS version?

7. ellipsize not working with TextView