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 results
Intent activityIntent = new Intent(context, ResultsActivity.class);
// this intent wraps results activity intent
PendingIntent resultsPendingIntent = PendingIntent.getActivity(context, 0, activityIntent, 0);

// this intent calls the speech recognition
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);

// this intent wraps voice recognition intent
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, voiceIntent, 0);
rv.setOnClickPendingIntent(R.id.btn, pendingIntent);
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值