我正在用uwp构建音乐播放器。窗户解锁后,敬酒通知上的操作按钮可以正常工作。当我锁定屏幕并单击操作按钮时,则什么也没有发生。应用程序将处于暂停状态,没有断点被击中。
即使锁定窗口以接收来自应用程序的事件,我如何使我的应用程序运行?
我面临的另一个问题是,当用户单击下一步时,上一个按钮的通知屏幕消失了。
即使用户单击任何操作按钮后,如何也可以在烤面包机通知屏幕上保留烤面包通知屏幕。
我用来创建通知的代码
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);
预先感谢
答案 0 :(得分:0)
最后,我使用protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args)
方法使它正常工作。