Issue
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. I need to add here my own software, so end user has a choice of using either Google Voice Search or my own app.
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.
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?
<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>
Solution
Use this intent : RecognizerIntent.ACTION_RECOGNIZE_SPEECH Here is the sample code on how it works.
// 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
Answered By - Taiko
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.