从乐队启动应用程序

时间:2016-01-21 18:15:02

标签: microsoft-band cortana

理论:在乐队上使用Cortana在手机上启动您的应用程序,该应用程序将与乐队通信,允许您的乐队自定义磁贴/按钮工作。

当你在手机上使用Cortana时,我有它的工作,但在乐队上使用Cortana它会尝试启动应用程序,但是它会挂在启动(应用程序名称)上,带有你的应用程序图标(基本上Cortana试图启动应用程序)。我甚至认为它不适用于app.xaml ..

这是我需要帮助的地方......

使用此页面让Cortana启动您的简单应用程序...... https://msdn.microsoft.com/en-us/library/windows/apps/mt185609.aspx?f=255&MSPPError=-2147217396

您必须将代码放入app.xaml.cs,以便在通过语音命令进入主页时导航到主页。

protected override void OnActivated(IActivatedEventArgs args)
    {
        if (args.Kind == ActivationKind.VoiceCommand)
        {
            Frame rootFrame = Window.Current.Content as Frame;
           // if (rootFrame == null)
            //{
                // Repeat the same basic initialization as OnLaunched() above, taking into account whether
                // or not the app is already active.
                rootFrame = Window.Current.Content as Frame;

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (rootFrame == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame = new Frame();

                    rootFrame.NavigationFailed += OnNavigationFailed;

                    if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                    {
                        //TODO: Load state from previously suspended application
                    }

                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                }

                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage));
                }
                Window.Current.Activate();
            }
       // }

    }

0 个答案:

没有答案