2
First I created the following xml:
<?xml version="1.0" encoding="utf-8" ?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">
<CommandSet xml:lang="pt-BR" Name="CommandSet_pt-BR">
<AppName> App2 </AppName>
<Example> Esse e um exemplo </Example>
<Command Name="Dando Oi">
<Example> testando Oi Aplicativo </Example>
<ListenFor> testando oi aplicativo </ListenFor>
<Feedback> Ok, vou te dar um ola</Feedback>
<Navigate />
</Command>
</CommandSet>
</VoiceCommands>
After this creation, I went to register the command in App.xaml.Cs, with the following code:
try
{
StorageFile vcd = await Package.Current.InstalledLocation.GetFileAsync(@"teste.xml");
await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcd);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
Together:
protected async override void OnActivated(IActivatedEventArgs args)
{
base.OnActivated(args);
if(args.Kind == ActivationKind.VoiceCommand)
{
VoiceCommandActivatedEventArgs cmd = args as VoiceCommandActivatedEventArgs;
SpeechRecognitionResult result = cmd.Result;
string commander = result.RulePath[0];
MessageDialog dialog = new MessageDialog("");
switch(commander)
{
case "testando oi aplicativo":
dialog.Content = "Funcionou";
break;
default:
break;
}
await dialog.ShowAsync();
}
}
Finally, I ran in Release mode. When I test the Port for my code, it only opens the browser, as if the app had not registered the command.
To facilitate help post the corresponding code snippet and explain exactly what you are trying to do.
– rubStackOverflow
Ready, Done :)
– Severino J. Da C. Neto