diff options
author | Mike LeBeau <mlebeau@android.com> | 2010-02-10 19:34:56 -0800 |
---|---|---|
committer | Mike LeBeau <mlebeau@android.com> | 2010-02-11 11:40:02 -0800 |
commit | 5d34e9b63d5305934dcedac11e8dd658ae23c174 (patch) | |
tree | 7a6c896c25efa8df5163d5ea4086cd1c3615e1e4 /core/java/android/speech | |
parent | 575c6710a38f608aca2c25e7784674a47d18a871 (diff) | |
download | frameworks_base-5d34e9b63d5305934dcedac11e8dd658ae23c174.zip frameworks_base-5d34e9b63d5305934dcedac11e8dd658ae23c174.tar.gz frameworks_base-5d34e9b63d5305934dcedac11e8dd658ae23c174.tar.bz2 |
Add new setting for the ComponentName of the service to be used
for voice recognition on the device. Right now this just queries
the package manager at boot and finds the (hopefully) single
available recognizer.
TODO: Add an attribute to let recognition services expose a settings
activity, and expose the settings activity of the chosen recognition
service in the system settings for voice input & output.
Diffstat (limited to 'core/java/android/speech')
-rw-r--r-- | core/java/android/speech/RecognitionManager.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/core/java/android/speech/RecognitionManager.java b/core/java/android/speech/RecognitionManager.java index 7915208..edb7067 100644 --- a/core/java/android/speech/RecognitionManager.java +++ b/core/java/android/speech/RecognitionManager.java @@ -27,6 +27,8 @@ import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.RemoteException; +import android.provider.Settings; +import android.text.TextUtils; import android.util.Log; import java.util.LinkedList; @@ -218,8 +220,20 @@ public class RecognitionManager { checkIsCalledFromMainThread(); if (mConnection == null) { // first time connection mConnection = new Connection(); - if (!mContext.bindService(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), - mConnection, Context.BIND_AUTO_CREATE)) { + + Intent serviceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); + String serviceComponent = Settings.Secure.getString(mContext.getContentResolver(), + Settings.Secure.VOICE_RECOGNITION_SERVICE); + + if (TextUtils.isEmpty(serviceComponent)) { + Log.e(TAG, "no selected voice recognition service"); + mListener.onError(ERROR_CLIENT); + return; + } + + serviceIntent.setComponent(ComponentName.unflattenFromString(serviceComponent)); + + if (!mContext.bindService(serviceIntent, mConnection, Context.BIND_AUTO_CREATE)) { Log.e(TAG, "bind to recognition service failed"); mConnection = null; mService = null; |