我试过Cortana语音命令来启动我的应用程序,
但是,只有当应用程序被暂停时,它才能工作。当app关闭时,它会显示Splash屏,然后app失败。我不能抓住任何例外。
A具有与https://msdn.microsoft.com/en-us/library/dn630430.aspx和麦克风功能完全相同的代码。
发布于 2015-02-16 20:27:12
当语音命令激活应用程序时,这个方法将被调用,而OnLaunched不会被调用。正因为如此,我们需要类似于我们在OnLaunched中的代码
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
rootFrame.CacheSize = 1;
Window.Current.Content = rootFrame;
rootFrame.Navigate(typeof(MainPage));
}发布于 2015-07-13 14:22:16
当使用语音命令打开应用程序时,需要在app.OnActivated方法上处理它:
protected override void OnActivated(IActivatedEventArgs e)
{
// Handle when app is launched by Cortana
if (e.Kind == ActivationKind.VoiceCommand)
{
VoiceCommandActivatedEventArgs commandArgs = e as VoiceCommandActivatedEventArgs;
SpeechRecognitionResult speechRecognitionResult = commandArgs.Result;
string voiceCommandName = speechRecognitionResult.RulePath[0];
string textSpoken = speechRecognitionResult.Text;
IReadOnlyList<string> recognizedVoiceCommandPhrases;
System.Diagnostics.Debug.WriteLine("voiceCommandName: " + voiceCommandName);
System.Diagnostics.Debug.WriteLine("textSpoken: " + textSpoken);
switch (voiceCommandName)
...如果您需要更多关于如何集成它的信息,请参阅此链接
https://stackoverflow.com/questions/28499314
复制相似问题