读书人

speech recognition中施用PendingInte

发布时间: 2012-08-08 14:32:45 作者: rapoo

speech recognition中使用PendingIntent

http://stackoverflow.com/questions/4530472/widget-that-calls-speech-recognition-app

http://stackoverflow.com/questions/6466328/recognizerintent-how-to-add-a-bundle-to-a-pending-intent

?

// this intent points to activity that should handle resultsIntent activityIntent = new Intent(context, ResultsActivity.class);// this intent wraps results activity intentPendingIntent resultsPendingIntent = PendingIntent.getActivity(context, 0, activityIntent, 0);// this intent calls the speech recognitionIntent 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);// this intent wraps voice recognition intentPendingIntent pendingIntent = PendingIntent.getActivity(context, 0, voiceIntent, 0);rv.setOnClickPendingIntent(R.id.btn, pendingIntent);
?

读书人网 >移动开发

热点推荐