烤通知操作按钮在锁定屏幕上不起作用
Toasted notifications action button is not working on lock screen
我正在 uwp 中构建音乐播放器。当 windows 解锁时,toasted 通知上的操作按钮工作正常。当我锁定屏幕并单击操作按钮时,什么也没有发生。应用程序将进入暂停状态,未命中任何断点。
即使 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)
方法让它工作了。
我正在 uwp 中构建音乐播放器。当 windows 解锁时,toasted 通知上的操作按钮工作正常。当我锁定屏幕并单击操作按钮时,什么也没有发生。应用程序将进入暂停状态,未命中任何断点。
即使 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)
方法让它工作了。