Permalink
Browse files

added hands-free intent parameter, might not work for all devices

  • Loading branch information...
1 parent 7f4b3bf commit 467ed71f6acd0a3bd0850083fdb529badbd8f507 @gmilette gmilette committed Mar 21, 2013
@@ -15,6 +15,10 @@
<string name="pref_websearch_title">Web Search</string>
<string name="pref_websearch_default">false</string>
+ <string name="pref_handsfree">pref_handsfree</string>
+ <string name="pref_handsfree_title">Hands Free</string>
+ <string name="pref_handsfree_default">false</string>
+
<string name="pref_direct">pref_direct</string>
<string name="pref_direct_title">Use SpeechRecognizer</string>
<string name="pref_direct_default">false</string>
@@ -34,6 +34,11 @@
android:key="@string/pref_websearch"
android:title="@string/pref_websearch_title" />
+ <CheckBoxPreference
+ android:defaultValue="@string/pref_handsfree_default"
+ android:key="@string/pref_handsfree"
+ android:title="@string/pref_handsfree_title" />
+
<CheckBoxPreference
android:defaultValue="@string/pref_direct_default"
android:key="@string/pref_direct"
@@ -514,6 +514,9 @@ private Intent readRecognizerIntentFromPreferences()
//web search handling
boolean isWebSearchAction = preferences.getBoolean(this, R.string.pref_websearch, R.string.pref_websearch_default);
+
+ boolean isHandsFreeAction = preferences.getBoolean(this, R.string.pref_handsfree, R.string.pref_handsfree_default);
+
if (isWebSearchAction)
{
intentToSend = RecognizerIntentFactory.getWebSearchRecognizeIntent();
@@ -525,7 +528,14 @@ private Intent readRecognizerIntentFromPreferences()
}
else
{
- intentToSend = RecognizerIntentFactory.getBlankRecognizeIntent();
+ if (isHandsFreeAction && Build.VERSION.SDK_INT >= 16)
+ {
+ intentToSend = RecognizerIntentFactory.getHandsFreeRecognizeIntent();
+ }
+ else
+ {
+ intentToSend = RecognizerIntentFactory.getBlankRecognizeIntent();
+ }
}
//language model
@@ -49,6 +49,12 @@ public static Intent getWebSearchRecognizeIntent()
return intent;
}
+ public static Intent getHandsFreeRecognizeIntent()
+ {
+ Intent intent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
+ return intent;
+ }
+
public static Intent getPossilbeWebSearchRecognizeIntent(String prompt)
{
Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);

0 comments on commit 467ed71

Please sign in to comment.