gpt4 book ai didi

android - 我需要在 Android 中将我的语音搜索应用程序添加到 “Complete action using”

转载 作者:行者123 更新时间:2023-11-30 04:28:56 26 4
gpt4 key购买 nike

我似乎找不到任何关于如何在按下搜索按钮时将我自己的程序(语音控制)添加到“使用完成操作”列表的示例。

现在,当您按下设备上的搜索按钮时,Google 语音搜索就会激活。我需要在此处添加我自己的软件,以便最终用户可以选择使用 Google 语音搜索或我自己的应用程序。

类似这个例子说明: http://support.launcherpro.com/images/complete%20action%20using%20lp_2.png,但我特别需要语音搜索操作的代码示例( Intent )。

再一次,当人们按下搜索按钮时,我想将我的应用程序映射到“Complete Action Using”列表。设备本身的搜索按钮,而不是在我的应用程序中。

我找到了这段代码(打开 .doc 文件时,它会将特定应用程序映射到菜单),但我该如何修改它,以便将我的应用程序添加到搜索按钮长按列表中?

      <activity android:name="ActivityTest" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:pathPattern=".*doc" />
</intent-filter>
</activity>

最佳答案

使用这个 Intent :RecognizerIntent.ACTION_RECOGNIZE_SPEECH这是有关其工作原理的示例代码。

// Check to see if a recognition activity is present
PackageManager pm = getPackageManager();
List activities = pm.queryIntentActivities(
new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
if (activities.size() != 0) {
speakButton.setOnClickListener(this);
} else {
speakButton.setEnabled(false);
speakButton.setText("Recognizer not present");
}

http://developer.android.com/resources/articles/speech-input.html

关于android - 我需要在 Android 中将我的语音搜索应用程序添加到 “Complete action using”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8060308/

26 4 0