我在uwp建立音乐播放器。当解锁窗户时,烘烤通知上的操作按钮正常工作。当我锁定屏幕并单击操作按钮时,没有任何事情发生。应用程序将暂停状态,没有破坏点被击中。
即使Windows被锁定以从应用程序接收事件,我如何使我的应用程序运行?
我面临的另一个问题是当用户点击下一个,之前的按钮通知屏幕消失。
即使在用户点击任何操作按钮后,如何在机器上保留Toasted通知屏幕。
我用来创建通知的代码
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);
提前致谢
最后我通过使用protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args)
方法得到了它。