[英]I need to add my Voice Search app to “Complete action using” in Android
I can't seem to be able to find any example of how to add my own program (voice control) to a “Complete action using” list, on search button press.我似乎无法找到任何示例,说明如何在按下搜索按钮时将我自己的程序(语音控制)添加到“使用完整操作”列表中。
Right now, when you press the search button on your device, Google Voice Search will activate.现在,当您按下设备上的搜索按钮时,Google 语音搜索就会激活。 I need to add here my own software, so end user has a choice of using either Google Voice Search or my own app.
我需要在此处添加我自己的软件,以便最终用户可以选择使用 Google 语音搜索或我自己的应用程序。
Something like this example illustrates: http://support.launcherpro.com/images/complete%20action%20using%20lp_2.png , but I need the code example (intent) for the voice search action in particular.类似这个例子的东西说明了: http://support.launcherpro.com/images/complete%20action%20using%20lp_2.png ,但我特别需要语音搜索操作的代码示例(意图)。
So again, I want to map my application to "Complete Action Using" list, when person presses the search button.再次,当人们按下搜索按钮时,我想将我的应用程序映射到“使用完整操作”列表。 Search button on the device itself, not in my application.
设备本身上的搜索按钮,而不是我的应用程序中。
I have found this code (which maps specific app to menu when .doc file is opened), but how do I amend it, so it adds my app to list on search button long press?我找到了这个代码(它在打开 .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>
Use this intent : RecognizerIntent.ACTION_RECOGNIZE_SPEECH Here is the sample code on how it works.使用这个意图: 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 http://developer.android.com/resources/articles/speech-input.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.