调用GOOGLE语音
生活随笔
收集整理的這篇文章主要介紹了
调用GOOGLE语音
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Activity中添加代碼 protected void onCreate(Bundle savedInstanceState) { /* 下面是判斷當前手機是否支持語音識別功能 */ PackageManager pm = mapIndex.curr.getPackageManager(); List list = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); if(list.size()==0) { com.uumap.mapview.Map.tipShow("請安裝google語音搜索"); }else{ Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); //設置為當前手機的語言類型 startActivityForResult(intent,REQUEST_CODE); } } 此方法返回搜索結果集合: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode==REQUEST_CODE&&resultCode==RESULT_OK) { try { yylist = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); if (yylist != null && yylist.size() > 0) { getPoiDialog().show(); } } catch (NullPointerException e) { // TODO Auto-generated catch block e.printStackTrace(); } } super.onActivityResult(requestCode, resultCode, data); }
轉載于:https://www.cnblogs.com/dive/archive/2012/08/27/2659051.html
總結
以上是生活随笔為你收集整理的调用GOOGLE语音的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Guru of the Week 条款0
- 下一篇: (转)C/C++ Linux 程序员必须