【问题标题】:Extending Android's Voice Search app扩展 Android 的语音搜索应用程序
【发布时间】:2010-10-29 21:20:46
【问题描述】:

是否可以扩展语音搜索应用程序?我知道我可以在我自己的应用程序中添加一个按钮来启动语音识别对话框,但我想知道我是否可以扩展语音搜索应用程序,当你长按物理“搜索”键时自动启动。

send text to [contact] [message]
listen to [artist/song/album]
call [business]
call [contact]
send email to [contact] [message]
go to [website]
note to self [note]
navigate to [location/business name]
directions to [location/business name]
map of [location]

我基本上想将我自己的操作添加到上面的列表中。

这可能吗,还是我必须自己创建?

【问题讨论】:

    标签: android


    【解决方案1】:

    总之,没有。该应用程序没有您正在寻找的扩展点。您必须完全编写自己的应用程序,这是其他人所做的事情。

    【讨论】:

    【解决方案2】:

    处理语音搜索

    的简单方法

    第 1 步在按钮点击时调用此方法

    public void startVoiceRecognition() {
        Intent intent = new Intent("android.speech.action.RECOGNIZE_SPEECH");
        intent.putExtra("android.speech.extra.LANGUAGE_MODEL", "free_form");
        intent.putExtra("android.speech.extra.PROMPT", "Speak Now");
        this.mContainerActivity.startActivityForResult(intent, 3012);
    }
    

    第 2 步 覆盖 onActivityResult 方法

    @ Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 3012 && resultCode == RESULT_OK) {
            ArrayList < String > matches = data.getStringArrayListExtra("android.speech.extra.RESULTS");
            String result= matches.get(0);
            //Consume result 
            edittext.setText(result);
        }
    }
    

    就是这样,完成

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-12
      • 1970-01-01
      • 2011-08-26
      • 1970-01-01
      相关资源
      最近更新 更多