Skip to content Skip to sidebar Skip to footer

Recognizerintent Not Working; "missing Extra Calling_package"

I'm having problems using the RecognizerIntent API on Android 2.2. When I call the API using this code: Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent

Solution 1:

I had the exact same problem. I was working on existing code that had android:launchMode="singleInstance" in the activity I was working on. This will not work for speechrecognizer intent. I changed it to android:launchMode="standard". Now let's see how it breaks the rest of my program :)

Solution 2:

Your original code:

Intentintent=newIntent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
startActivityForResult(intent, REQUEST_CODE_VOICE_SEARCH);

Works correctly. I tested it on my device (HTC Desire), and also compared it to other open-source uses, by executing the following query in Google, and browsing the source code.

RecognizerIntent.ACTION_RECOGNIZE_SPEECH site:code.google.com

One of the output lines in my logcat looks like this:

01-2613:28:53.268: INFO/RecognitionController(1459): startRecognition(#Intent;action=android.speech.action.RECOGNIZE_SPEECH;component=com.google.android.voicesearch/.IntentApiActivity;B.fullRecognitionResultsRequest=true;S.android.speech.extra.LANGUAGE_MODEL=web_search;S.calling_package=com.test;end)

Run a similar search with one of the built in apps (or downloaded ones), see that it works (and is not a device issue, etc.).

If that works correctly, take the code to a new test project, simply put those lines in the onCreate (Change the result constant to 0), and see if it works.

Solution 3:

Have you tried setting the extra yourself?

Intentintent=newIntent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
intent.putExtra("calling_package","com.yourpackagename.YourActivityClassName");
startActivityForResult(intent, REQUEST_CODE_VOICE_SEARCH);

This is the approach used by this code and is the suggested solution to a similar issue.

Post a Comment for "Recognizerintent Not Working; "missing Extra Calling_package""