扩展安卓语音搜索应用程序

10

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

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]

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

这是否可能,还是我必须创建自己的列表?

2个回答

2
总之,不行。这个应用程序没有您要找的扩展点。您必须完全编写自己的应用程序,其他人已经做过了。

据我所知没有,但你可能会发现这个链接很有用:http://android-developers.blogspot.com/2010/03/speech-input-api-for-android.html - Rohan Singh

0
一个简单的方法来处理语音搜索
步骤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);
}

第二步 重写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);
    }
}

这就是全部,完成了


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接