这篇Speech recognition quickstart文章指示我
...将全局变量(HResultPrivacyStatementDeclined)初始化为HResult值0x80045509
代码是:
private static uint HResultPrivacyStatementDeclined = 0x80045509;
和
catch (Exception exception)
{
// Handle the speech privacy policy error.
if ((uint)exception.HResult == HResultPrivacyStatementDeclined)
{
resultTextBlock.Visibility = Visibility.Visible;
resultTextBlock.Text = "The privacy statement was declined.
Go to Settings -> Privacy -> Speech, inking and typing, and ensure you
have viewed the privacy policy, and 'Get To Know You' is enabled.";
// Open the privacy/speech, inking, and typing settings page.
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-accounts"));
}
else
{
var messageDialog = new Windows.UI.Popups.MessageDialog(exception.Message, "Exception");
await messageDialog.ShowAsync();
}
}
但是,我们应该把这些代码放在哪里?在 App.xaml.cs ?
中