简体   繁体   中英

How to show a scheduled dialog in a Windows Phone 8.1 Runtime app?

I'm trying to code a Timer-App with C# for Windows Phone 8.1 Runtime. My goal is to show a dialog and play a sound file when the timer is ended. If the user press "OK" the sound is stopped. Also a "Snooze" function would be great. Maybe not in this app, but I'm planning a personalized alarm clock too. Because I could add the TimeSpan for the timer to DateTime.Now it would be the easiest way to trigger at a specified time. Here are some ideas i had, but they don't do exactly what I want.

  • Register a background task. But there's no trigger for a specified time. Only a TimeTrigger which fires at most every 30 min. A solution, not very resource friendly, methinks, would be to look up if the expected time is within the next 30 minutes and await the specified time in the background task and use a ContantDialog. Not sure if this is possible at all.
  • Another possibility is to use a toast notification, but there is no possibility of interaction and it is not very impressive, if you want someone to notice the timer.
  • Alarms and Reminders are no longer available for RT apps...

Is there no other way? If there is a trigger for background tasks if internet connection is active, isn't there any trigger for a scheduled time? Or maybe a possibility to code something like the old Alarms and Reminders by myself?

Sorry that there is no code. But I don't have some useful code for this problem yet.

How would you solve this problem? Maybe for a timer, an alarm clock, a calender, a task reminder or something else that needs an interaction at a scheduled time. Thanks for your help.

The only real way to achieve this is with an Alarm, which (as you note) is Silverlight only.

For a runtime app a toast is closest, but isn't as alarmy. Once the user taps the toast (if at all) then it can launch the app for more detail. Toasts (especially when linked to a tile update) are good for calendar and task reminders, but if you want an alarm you really need the (Silverlight-only) Alarm API.

A Background Task cannot show any UI (other than raising a toast, which doesn't need the background task), so even if you could get the timing right it couldn't show the ContentDialog.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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