I have a widget that have only one button.. I read that the Listener should be set like this :
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
views.setOnClickPendingIntent(R.id.button1, pendingIntent);
But I have this code :
try {
sr = SpeechRecognizer
.createSpeechRecognizer(context);
sr.setRecognitionListener(new MainActivity().new listener());
Intent intent = new Intent(
RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
"voice.recognition.test");
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
sr.startListening(intent);
} catch (Exception e) {
Toast.makeText(context, "Exc: " + e, Toast.LENGTH_LONG).show();
}
that should be the onClick event.. I can't make that a pending intent..
Any Idea ? :)