XML文件:
<toast duration="long" launch="alarm(eb6c47a8-e5e2-40d0-bc4e-3aa957f36484)"> <visual> <binding template="ToastimageAndText04"> <text ID="1">Alarm App</text> <text ID="2">Alarm Test</text> <text ID="3">Time to wake up!</text> </binding> </visual> <audio loop="true" src="ms-winsoundevent:Notification.LooPing.Alarm2" /> <commands scenario="alarm"> <command ID="snooze" /> <command ID="dismiss" /> </commands></toast>
通知类:
public class Notification{ public async Task CreateNotification() { StorageFolder storageFolder = Package.Current.InstalledLocation; var toast = await storageFolder.GetfileAsync("toast.xml"); var xml = await fileIO.ReadTextAsync(toast); NotifyScheduled(xml); } private voID NotifyScheduled(string toast,int delay = 5,int snooze = 300,int maxSnoozeCount = 3) { Xmldocument document = new Xmldocument(); document.LoadXml(toast); var notifIEr = Toastnotificationmanager.CreatetoastNotifIEr(); var scheduledToast = new ScheduledToastNotification(document,DateTime.Now.AddSeconds(delay),TimeSpan.FromSeconds(snooze),(uint)maxSnoozeCount); notifIEr.AddToSchedule(scheduledToast); }}
并在Phone的xaml.cs页面中实现:
var note = new Notification();note.CreateNotification();
结果应如下所示:
但它目前只是像这样做一个常规的吐司通知(在你根据需要解雇或打盹之前不会发出警报):
就像我提到的,我可以让它在windows平板电脑(windows 8.1)中正常工作,它看起来像这样:
编辑:值得注意的是,如果您的平板电脑设备没有将您的应用程序指定为默认警报应用程序(只能分配一个),则不会显示“暂停/关闭”按钮.但是,在windows Phone 8.1中,没有选项可以定义默认警报应用程序的内容.
解决方法 不幸的是(因为我也需要警报),目前似乎不可能.这是一篇关于windows Phone 8.0和8.1中的功能的非常好的文章,以及它们如何映射以及可以在哪里执行的 *** 作:http://msdn.microsoft.com/en-us/library/dn642486(v=vs.105).aspx
有一节(第一节)叫
windows Phone 8 features for which there is no windows Phone Store equivalent
在其中,你可以看到
总结Alarms and reminders
以上是内存溢出为你收集整理的c# – 在Windows Phone 8.1 Universal Store App中触发警报?全部内容,希望文章能够帮你解决c# – 在Windows Phone 8.1 Universal Store App中触发警报?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)