Can I create an alarm clock app for the Window Universal App?

I would like to create an alarm application.

I found a way the timer works in the background. But the APIs that control the display power were not found (I want to turn on the power of the display when its power is off).

Does Windows 10 (Windows Universal App) have enough APIs to create this application?

+5
source share
4 answers

Windows-universal-samples has recently been updated with several new RTM samples, including this one - Notifications .

As Anxiety is also a type of notification, it is now integrated into the new toast notification infrastructure in the universal Windows platform.

After you have downloaded the source code from the notification method above, start it with RTM for Visual Studio 2015, and then, as soon as the application is downloaded, go to

toasts> scripts> script: alarm clock

and you will see a fully functional alarm application (along with a reminder and many other samples).


Tell us about the code.

Basically, unlike Windows Phone Silverlight, now you can configure the alarm popup to indicate the xml payload like this (make sure the scenario parameter is set to alarm )

 <toast launch='args' scenario='alarm'> <visual> <binding template='ToastGeneric'> <text>Alarm</text> <text>Get up now!!</text> </binding> </visual> <actions> <action arguments = 'snooze' content = 'snooze' /> <action arguments = 'dismiss' content = 'dismiss' /> </actions> </toast> 

And then create an XmlDocument that loads the above xml string

 var xmlString = @"//copy above xml here//"; var doc = new Windows.Data.Xml.Dom.XmlDocument(); doc.LoadXml(xmlString); 

Then create a ToastNotification and run it using ToastNotificationManager -

 var toast = new ToastNotification(doc); ToastNotificationManager.CreateToastNotifier().Show(toast); 

What is it! You will see an alarm popup as shown below. enter image description here


Update

Microsoft recently responded to one of my API requests , and I am posting content here so that everyone knows which APIs have been added and which still do not.

What is done

  • Now there is a way to create an alarm / reminder in the universal windows of the application;
  • An alarm / reminder supports user snooze time (you can choose whether the system processes the delay or awakens the background task to do it manually);
  • An alarm / reminder only supports vibration (just like a toast), which can be overwritten by the user to turn off the vibration;
  • An alarm / reminder supports a good level of customization (user optional inline image, custom additional actions, etc.).

Some links

What we (MSFT) know is missing and we hope for support in the near future

  • Support for native platforms in the alarm / reminder mode for automatic time conversion when changing the time zone (workaround - this can be done by the application manually using the TimeZoneChange trigger);
  • Built-in platform support in the alarm / reminder mode of repetition events (workaround - this can only be done manually by the application manually, periodically waking up and replanting a bunch of alarms / reminders in advance);

  • Support for your own platform for selecting a song from the music library as a ringtone for an alarm / reminder (a workaround is to do this by reading and copying files from your music library, and then use the saved / modified version of the file in your application or application data as ringtones (toast notification supports custom sound, pointing to files in appx or appdata in the xml payload)).

+17
source

AlarmApplicationManager can be used to create alarm applications. It gives you the ability to schedule toast notifications.

 var scheduledToast = new ScheduledToastNotification(content, DateTime.Now.AddMinutes(5)); toastNotifier.AddToSchedule(scheduledToast); 

The sound source can also be set when creating a toast template, but only from the set of predefined sounds provided by the windows.

Refer to AlarmApplicationManager and Build an Alarm App for more details.

+2
source

GitHub has several Win 10 Universal Samples that may be useful. However, I have not seen anything directly related to Alarms.

+2
source

Unfortunately, Windows Universal Applications do not have direct access to display settings. But you can use the AlarmApplicationManager Class to create an Alarm. In some cases (probably in WindowsPhone) this will automatically appear on the display to show an alarm (with a title and description).

0
source

All Articles