C# 烤面包通知操作按钮在锁屏上不工作
我正在uwp中构建音乐播放器。当窗口解锁时,toasted通知上的操作按钮工作正常。当我锁定屏幕并单击“操作”按钮时,什么也没有发生。应用程序将处于暂停状态,未命中断点 即使windows被锁定从应用程序接收事件,我如何使我的应用程序运行 我面临的另一个问题是,当用户单击“下一步”时,上一个按钮通知屏幕将消失 即使在用户单击任何操作按钮后,我如何保持机器上的烤面包通知屏幕 我用来创建通知的代码C# 烤面包通知操作按钮在锁屏上不工作,c#,wpf,uwp,toast,C#,Wpf,Uwp,Toast,我正在uwp中构建音乐播放器。当窗口解锁时,toasted通知上的操作按钮工作正常。当我锁定屏幕并单击“操作”按钮时,什么也没有发生。应用程序将处于暂停状态,未命中断点 即使windows被锁定从应用程序接收事件,我如何使我的应用程序运行 我面临的另一个问题是,当用户单击“下一步”时,上一个按钮通知屏幕将消失 即使在用户单击任何操作按钮后,我如何保持机器上的烤面包通知屏幕 我用来创建通知的代码 var toastContent = new ToastContent {
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);
提前感谢最后,我通过使用
受保护的override async void on backgroundactivated(BackgroundActivatedEventArgs args)
方法使它工作起来