public static async Task <bool> RunActivationProcedureAsync(ActivationArgs activationArgs)
        {
            if (activationArgs == null)
            {
                return(false);
            }

            switch (activationArgs.ActivationKind)
            {
            case ActivationKind.Protocol:
                return(await ActivateForProtocolAsync(activationArgs.ProtocolUri));

            case ActivationKind.VoiceCommand:
                return(await ActivateForVoiceAsync(activationArgs.SpeechCommand));
            }

            return(false);
        }
Example #2
0
        /// <summary>
        /// Invoked when the application is activated by an outside source, i.e. protocol or Cortana.
        /// </summary>
        /// <param name="args">
        /// Details about the activation.
        /// </param>
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            ActivationArgs activationArgs = null;

            switch (args.Kind)
            {
            case ActivationKind.Protocol:
                var protocolArgs = args as ProtocolActivatedEventArgs;
                if (protocolArgs != null)
                {
                    activationArgs = new ActivationArgs(protocolArgs.Uri);
                }
                break;

            case ActivationKind.VoiceCommand:
                var voiceArgs = args as VoiceCommandActivatedEventArgs;
                if (voiceArgs != null)
                {
                    var result       = voiceArgs.Result;
                    var voiceCommand = result.RulePath[0];

                    var speechCommand = new SpeechCommand(result, new List <string>());

                    // Switch on the voice command string to determine function

                    activationArgs = new ActivationArgs(speechCommand);
                }
                break;
            }

            var rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                await this.LaunchApplicationAsync(activationArgs);
            }
            else
            {
                await ActivationLauncher.RunActivationProcedureAsync(activationArgs);
            }

            base.OnActivated(args);
        }
        /// <inheritdoc />
        public override async void OnPageNavigatedTo(NavigationEventArgs args)
        {
            this.activationArgs = args.Parameter as ActivationArgs;

            this.IsLoading = true;

            var initializeSuccess = await this.initializer.InitializeAsync();

            if (initializeSuccess)
            {
                var activated = await ActivationLauncher.RunActivationProcedureAsync(this.activationArgs);

                if (!activated)
                {
                    this.NavigateToHome();
                }

                NavigateToShell();
            }

            this.IsLoading = false;
        }