Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am building music player in uwp. Action buttons on the toasted notification are working fine when windows are unlocked. when i locked the screen and click on action button then nothing is happening. Application is going to pause state, no break points are getting hit.

How can i make my application to run even when windows is locked to receive events from app?

Another problem I am facing is when user clicks on next, previous buttons notification screen goes away.

How can i keep the Toasted notification screen on the machine even after user clicks on any action button.

Code i am using to create notification

var toastContent = new ToastContent
            {
                Launch= "",
                Visual = new ToastVisual
                {
                    BindingGeneric = new ToastBindingGeneric
                    {
                        Children =
                        {
                            new AdaptiveText
                            {
                                 HintWrap = false,
                            HintMaxLines = 1,
                            HintStyle = AdaptiveTextStyle.Title,
                                Text = "sdfsd"
                            },
                            new AdaptiveText
                            {
                                 HintWrap = false,
                            HintMaxLines = 1,
                            HintStyle = AdaptiveTextStyle.Caption,
                                Text = "text"
                            }
                        },

                        AppLogoOverride = new ToastGenericAppLogo()
                        {
                            Source = optionalLogoPath
                        }
                    }
                },
                Actions = new ToastActionsCustom()
                {
                    Buttons =
                {
                    new ToastButton("previous", new QueryString()
                    {
                        { "action", "previous" }

                    }.ToString() )
                    {
                        ActivationType= ToastActivationType.Foreground,
                        ImageUri = "prev-focus.png",

                    },
                    new ToastButton("Play", new QueryString()
                    {
                        { "action", "play" }

                    }.ToString() )
                    {
                        ActivationType= ToastActivationType.Foreground,
                        ImageUri = "play-focus.png",

                    },
                    new ToastButton("next", new QueryString()
                    {
                        { "action", "next" }

                    }.ToString() )
                    {
                        ActivationType= ToastActivationType.Background,
                        ImageUri = "next-focus.png"
                    },

                },
                }
            };

            var toast = new ToastNotification(toastContent.GetXml())
            {
                Tag = "some tag",
                SuppressPopup = false
            };

            toastNotifier.Show(toast);

Thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
395 views
Welcome To Ask or Share your Answers For Others

1 Answer

Finally i got it working by using protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args) method.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...