我想创建一个闹钟应用程序.
我找到了在后台操作计时器的方法.但是没有找到控制显示器电源的API(我想在显示器电源关闭时打开显示器的电源).
Windows 10(Windows 通用应用)是否没有足够的 API 来创建该应用?
微软最近回复了 我的一个 API 请求,我在此处发布内容,以便大家知道哪些 API 已添加,哪些尚未完成.
做了什么
一些参考资料
适用于 Windows 10 的自适应交互式 Toast 通知
适用于 Windows 10 的 Toast 通知和操作中心概述
快速入门:发送本地toast通知及处理从中激活(Windows 10)
我们 (MSFT) 知道缺少的内容并希望在不久的将来支持
本机平台支持重复事件的警报/提醒(解决方法 - 目前只能通过应用手动定期唤醒并提前重新安排一堆警报/提醒来完成);
原生平台支持从音乐库中选择一首歌曲作为闹钟/提醒的铃声(解决方法 - 这可以通过从音乐库中读取和复制文件来完成,然后使用保存/修改的您的应用程序包中的文件版本或应用程序数据作为铃声(toast 通知通过指向 xml 有效负载中的 appx 或 appdata 中的文件支持自定义声音)).
I would like to create an alarm app.
I found the way of operating a timer in the background. But APIs which control the power of the display were not found(I want to turn on the display's power when its power is off).
Doesn't Windows 10 (Windows Universal App) have enough APIs to create that app?
Windows-universal-samples has recently been updated with a few new RTM samples including this one - Notifications.
As Alarm is also one type of notification, it's now built within a new toast notification framework in the Universal Windows Platform.
After you downloaded the source code from the Notification's link above, run it with Visual Studio 2015 RTM and then once the app is loaded, go to
toasts > scenarios > scenario: alarm
and you will see a fully functional alarm app (along with Reminder and a lot other samples).
Let's talk about code.
Basically, unlike in Windows Phone Silverlight, you can now customise the alarm popup a bit by specifying the xml payload like this (make sure the scenario
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 which 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 trigger it with ToastNotificationManager
-
var toast = new ToastNotification(doc);
ToastNotificationManager.CreateToastNotifier().Show(toast);
That's it! You will see an alarm popup like below.
Microsoft recently responded to one of my API requests and I am posting the content here so everyone knows what APIs have been added and what are still outstanding.
What has been done
Some references
Adaptive and interactive toast notifications for Windows 10
Toast Notification and Action Center Overview for Windows 10
Quickstart: Sending a local toast notification and handling activations from it (Windows 10)
What we (MSFT) know that’s missing and hope to support in the near future
Native platform support in alarm/reminder for recurrence events (Workaround – this can currently only be done by the app manually periodically waking up and reschedule a bunch of alarms/reminders ahead of time);
Native platform support to select a song from Music library as ring tone for alarm/reminder (Workaround – this can be done by reading and copying files from your music library, and then use the saved/modified version of the file in your app package or app data as the ring tone (toast notification supports custom sound by pointing to files in appx or appdata in the xml payload)).
这篇关于我可以为Window Universal App创建一个警报应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!