In the previous blog post, we have already demonstrated How to Integrate Cortana through Three easy steps and we walked through the First Step “Create Voice Command Definition File”.
In this blog post, we will walk through the Second Step “Register VCD xml file on App Startup”.
2. Register VCD xml file on App Startup
After Creating the Voice Command Definition File, we have to register this file on App Startup to let the Phone System and Cortana able to Recognize these Commands.
To Register the VCD File:
- Open App.xaml.cs
- Add this snippet of code in OnLaunced Method
Uri uriVoiceCommands = new Uri("ms-appx:///vcd.xml", UriKind.Absolute); StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uriVoiceCommands); await VoiceCommandManager.InstallCommandSetsFromStorageFileAsync(file);
And this code should be performed under Try/Catch to Handle Exception Errors.
Now, you have already Created your Voice Command Definition File and Registered this file on your App Startup.
Go to the Next step:
Integrating Cortana | Part 3