我正在编写一个 UWP 应用程序,并且我有一个 ScheduledToastNotification,当应用程序暂停时(例如提醒)添加到日程表中。但是,如果我关闭应用程序,通知会按时出现,但是当我单击通知(没有按钮,一般只是在通知上)时,应用程序无法正确启动,在启动画面处停止。
如何正确重新启动应用程序?
谢谢。
最佳答案
您应该在 OnActivated
中覆盖 App.Xaml.cs
并像这样处理
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.ToastNotification)
{
var toastArgs = args as ToastNotificationActivatedEventArgs;
var arguments = toastArgs.Argument;
if (arguments == "ARG")
{
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
Window.Current.Content = rootFrame;
}
rootFrame.Navigate(typeof(YOURPAGE));
Window.Current.Activate();
}
}
}
关于c# - UWP C# - 从通知点击重新启动应用程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37636189/