I wrote a small application so that the user can choose in which language he uses Voice Search by pressing a button, instead of relying on the user's preferences (sometimes you want the voice to be in Japanese, without switching the entire user interface to Japanese).
I am testing the application on my HTC Desire / Android 2.1 (Softbank-x06ht). However, when I call the api voice, I get the “Connection Failed” dialog box [retry / cancel], and LogCat shows this warning:
09-12 11:26:13.583: INFO/RecognitionService(545): ssfe url=http://www.google.com/m/voice-search
09-12 10:49:45.683: WARN/RecognitionService(545): required parameter 'calling_package' is missing in IntentAPI request
Please note that I can use the Google Voice Search application and it works without problems.
According to the API Docs http://developer.android.com/reference/android/speech/RecognizerIntent.html#EXTRA_CALLING_PACKAGE, the call_package parameter will not be used by developers. Well, if so, why does the magazine say that it is missing?
I tried to provide the parameter myself, but it did not change the result at all.
private static final String TRIVOICE_CALLING_PACKAGE = "calling_package";
private void callSpeechWebSearch (String language) {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE,
language);
intent.putExtra(TRIVOICE_CALLING_PACKAGE,
"org.filsa.trivoice");
try {
startActivity(intent);
} catch (ActivityNotFoundException anfe) {
makeToast("ANFE:" +anfe.getMessage());
}
}
filsa source
share