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.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
startActivityForResult(intent, REQUEST_CODE_VOICE_SEARCH);
which looks like it should work, a search popup says “Unknown issue” on the device and in its logs:
01-17 14:25:30.433: ERROR/RecognitionActivity(9118): ACTION_RECOGNIZE_SPEECH intent called incorrectly. Maybe you called startActivity, but you should have called startActivityForResult (or otherwise included a pending intent).
01-17 14:25:30.433: INFO/RecognitionControllerImpl(9118): startRecognition(
01-17 14:25:30.433: INFO/RecognitionControllerImpl(9118): State change: STARTING -> STARTING
01-17 14:25:30.443: ERROR/RecognitionControllerImpl(9118): required extra 'calling_package' missing in voice search intent
01-17 14:25:30.443: ERROR/RecognitionControllerImpl(9118): ERROR_CLIENT
01-17 14:25:30.443: ERROR/RecognitionControllerImpl(9118): ERROR_CLIENT
It seems that the problem is that the "call_package" extra is missing; The RecognizerIntent page indicates that this is optional:
An additional key used in the intent of the speech recognizer for voice search. Usually not used by Developers. The system search dialog uses this, for example, to install a calling package to identify the voice search API. If it is additionally installed by anyone other than the system process, it must be canceled by the search voice.
As far as I can tell, I don't need to redefine this add-on, so why am I getting this error? How can I fix my code?
source
share