简体   繁体   English

Windows Phone 8.1中的警报代码

[英]Alarm code in Windows Phone 8.1

I have code the app with future Reminder by Toast notification , i can remind every times by BackgroundTask 我已经使用Toast通知对未来的Reminder进行了代码编写,我可以通过BackgroundTask每次提醒

But i want to reminder at one time in every day like : 4.00 PM every day 但我想在每天的某个时刻提醒,如:每天下午4点

I search and get info about Alarm and Reminder are out of Windows Phone 8.1 我搜索并获取有关警报和提醒的信息不在Windows Phone 8.1中

So have another way ? 那么有另一种方式吗?

Sorry my bad English 抱歉,我的英语不好

You can use a scheduled toast notification to fire a toast at a specific time. 您可以使用预定的Toast通知在特定时间触发Toast。 This doesn't require the app be running when the toast fires, only when the toast is scheduled. 这不需要应用程序在吐司点火时运行,只有在预定吐司时才会运行。

You will need to schedule individual toasts for each day as there is no automatic repetition. 由于没有自动重复,您需要为每天安排单独的吐司。 If the user is likely to run the app frequently then you can schedule the next 30 days or so whenever the app runs. 如果用户可能经常运行应用程序,那么只要应用程序运行,您就可以安排接下来的30天左右。 Another option is to set a MaintainanceTrigger background task to schedule the next 30 days every so often when the app is plugged in. 另一种选择是设置MaintainanceTrigger后台任务,以便在插入应用程序时经常安排接下来的30天。

            // Today, 4:00pm
        DateTime now = DateTime.Now;
        DateTime dueTime = new DateTime(now.Year, now.Month, now.Day, 16, 0, 0);
        ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();

        for(int i=0;i<30;i++)
        {
            dueTime.AddDays(1);
            XmlDocument toastXml = SetupMyToast(dueTime);

            ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, dueTime);
            toastNotifier.AddToSchedule(scheduledToast);
        }

For more details see Quickstart: Sending a toast notification (XAML) and How to schedule a toast notification 有关更多详细信息,请参阅快速入门:发送Toast通知(XAML) 和如何安排Toast通知

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM