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. Dalvik Turbo "up to three times" faster, all while reducing battery drai

Bagus untuk tukang sulap gw yang mulai tua....

Swiss firm claims huge boost in Android app performance, battery life with
new virtual machine
By Chris Ziegler <http://www.engadget.com/editor/chris-ziegler>
<http://www.engadget.com/editor/chris-ziegler/rss.xml>
 posted Feb 9th 2010 6:35AM
<http://www.myriadgroup.com/Media-Centre/News/MYRIAD-BRINGS-3x-FASTER-APPLICATIONS-RICHER-GAME-GRAPHICS-AND-BETTER-BATTERY-LIFE-TO-ANDROID.aspx>At
the core of Anrdoid lies a little bundle of code known as the Dalvik virtual
machine, a runtime environment for Java apps that's specifically optimized
for hardware with limited memory and processor power -- you know, the kind
of situation you find in your average smartphone. The relative success of
the Android Market suggests that Dalvik's getting the job done on some level
(as long as you're not looking for a texture-intense FPS), but the fact that
Google bothered to create a separate native development
kit<http://www.engadget.com/2009/06/25/android-1-5-gets-official-sdk-for-native-development/>
to
speed up intensive operations certainly serves as a damning counterpoint.
Enter Swiss firm Myriad -- a founding and code-contributing member of the
OHA <http://www.engadget.com/tag/OHA/>, coincidentally -- which is touting
this week that it's crafted a much higher-performance replacement for
Dalvik, appropriately known as "Dalvik Turbo." Just how much
higher-performance are we talking? *Myriad claims apps run in Dalvik Turbo
"up to three times" faster, all while reducing battery drain and giving devs
the power they need to create graphically intense games*. Even better, it
apparently maintains complete compatibility with existing Android apps and
is available for all the key mobile platforms -- ARM, Atom, and MIPS
included -- and is virtually guaranteed to make you sob uncontrollably to
learn that your Android 1.5, 1.6, 2.0, or 2.1-based device isn't using it.
It'll be on display at MWC <http://www.engadget.com/tag/MWC/> next week, so
we're looking forward to finally seeing Gang Wars humming along at 60fps on
a G1.

-- 

http://hobby.keluargareski.net
Sent by XPS via gmail

-- 
"Indonesian Android Community [id-android]" 

2. Window System Bug: phonewin...@decorview gets wrong Window size, width/height

1. Popup Dialog with ListView
2. Slide open, close, repeat, and do fast
3. Sometimes in Slide close state, the dialog is show in 320X320
window instead of the right 320X480

Thanks!
Guobin

-- 

3. OOT: Paging ntil & suhu SA

4. Why setting TextView.Ellipsize as Marquee cause its sibling view in linearlayout redraw

5. pause

6. This Week's office hours

7. drawing children in custom linearlayout