Hi, I have some troubles with implementing SpeechRecognizer, which is called
from my widget. Here is a snippet of code:
private PendingIntent startVoiceRecognitionActivity(Context context) {
Intent activityIntent = new Intent(context, MainActivity.class);
PendingIntent resultsPendingIntent = PendingIntent.getActivity(context, 0,
activityIntent, 0);
Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speech recognition
demo");
voiceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT,
resultsPendingIntent);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
voiceIntent, 0);
return pendingIntent;
}
PendingIntent pendingIntent = startVoiceRecognitionActivity(context);
remoteView.setOnClickPendingIntent(R.id.widget_button_save, pendingIntent);
Everytime when the SR activity want to return recognized data it fall down
with this exception:
E/AndroidRuntime( 2854): Uncaught handler: thread pool-1-thread-1 exiting
due to uncaught exception
E/AndroidRuntime( 2854): java.lang.NullPointerException
E/AndroidRuntime( 2854): at
com.google.android.voicesearch.RecognitionActivity.forwardRecognitionResults(RecognitionActivity.java:925)
E/AndroidRuntime( 2854): at
com.google.android.voicesearch.RecognitionActivity.handleIntentApiResults(RecognitionActivity.java:898)
E/AndroidRuntime( 2854): at
com.google.android.voicesearch.RecognitionActivity.access$500(RecognitionActivity.java:67)
E/AndroidRuntime( 2854): at
com.google.android.voicesearch.RecognitionActivity$VoiceSearchRecognitionListener.onResults(RecognitionActivity.java:147)
E/AndroidRuntime( 2854): at
com.google.android.voicesearch.RecognitionService.searchResults(RecognitionService.java:647)
E/AndroidRuntime( 2854): at
com.google.android.voicesearch.speechservice.SpeechServiceRecognizer.fireSearchResult(SpeechServiceRecognizer.java:1344)
E/AndroidRuntime( 2854): at
com.google.android.voicesearch.speechservice.SpeechServiceRecognizer.processApiResult(SpeechServiceRecognizer.java:683)
E/AndroidRuntime( 2854): at
com.google.android.voicesearch.speechservice.SpeechServiceRecognizer.processResponse(SpeechServiceRecognizer.java:671)
E/AndroidRuntime( 2854): at
com.google.android.voicesearch.speechservice.SpeechServiceRecognizer.recognize(SpeechServiceRecognizer.java:600)
E/AndroidRuntime( 2854): at
com.google.android.voicesearch.RecognitionService.startRecognitionInternal(RecognitionService.java:313)
E/AndroidRuntime( 2854): at
com.google.android.voicesearch.RecognitionService.access$400(RecognitionService.java:74)
E/AndroidRuntime( 2854): at
com.google.android.voicesearch.RecognitionService$RecognitionRunnable.run(RecognitionService.java:546)
E/AndroidRuntime( 2854): at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
E/AndroidRuntime( 2854): at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
E/AndroidRuntime( 2854): at java.lang.Thread.run(Thread.java:1096)
I hope, anyone can help me.
Thank in advance
Honza
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en