0
我有隻有一個按鈕的控件。我讀聽者應該設置這樣的:設置onClickListener一個按鈕控件
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
views.setOnClickPendingIntent(R.id.button1, pendingIntent);
但我有這樣的代碼:
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();
}
這應該是onClick事件..我不能使這一等待意圖..
任何想法? :)