【发布时间】:2016-12-16 16:06:18
【问题描述】:
我正在开发一个在 Kindle Fire 上使用的增强通信应用程序。我使用 Fire HD 6 作为我的测试设备。我在 Xamarin 中工作,C#。
我知道当麦克风图标出现在键盘上时,设备上有一个语音识别器,我可以使用它来填充搜索窗口。但是,我的安卓语音识别器代码不起作用。我收到“识别器不存在”错误。这是我正在使用的代码:
public class VoiceRecognition : Activity
{
private static String TAG = "VoiceRecognition";
private const int VOICE_RECOGNITION_REQUEST_CODE = 1234;
private ListView mList;
public Handler mHandler;
private Spinner mSupportedLanguageView;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
mHandler = new Handler();
SetContentView(Resource.Layout.Main);
Button speakButton = FindViewById<Button>(Resource.Id.btnRecord);
// Check to see if a recognition activity is present
PackageManager pm = PackageManager;
IList<ResolveInfo> activities = pm.QueryIntentActivities(new Intent(RecognizerIntent.ActionRecognizeSpeech), 0);
if (activities.Count != 0)
speakButton.Click += speakButton_Click;
else
{
speakButton.Enabled = false;
speakButton.Text = "Recognizer not present";
}
}
这段代码显然行不通,但我不知道从哪里开始。如何访问此设备上的语音识别器?
谢谢!
【问题讨论】:
标签: c# android xamarin.android voice-recognition kindle-fire