自定义通知间隔 [英] Custom notification interval

查看:167
本文介绍了自定义通知间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Rad Studio XE8下的FireMonkey中构建应用程序。

I am building an app in FireMonkey under Rad Studio XE8.

我希望在通知(FMX.Notification)上设置自定义间隔。

I would like to have custom intervals on my notifications (FMX.Notification).

但是通知重复只能设置为特定间隔。

However notification repeats can only be set to certain intervals.

TRepeatInterval = (None, Second, Minute, Hour, Day, Week, Weekday, Month, Quarter, Year, Era);

如果我想每15分钟触发一次,我真的需要创建四个通知(在0时, 15、30、45分钟),然后每小时使用TRepeatInterval(4)重复一次?

If i whant to fire each 15 minutes, would I really need to create four notification (at 0 , 15, 30, 45 minutes) and repeat them every hour with TRepeatInterval(4)?

推荐答案

文档,用于 FMX.Notification.TNotification.RepeatInterval 强调说:


如果您要设置自定义间隔,例如30分钟,则需要创建两个通知,使用FireDate设置30分钟的计划时间差,并将两个通知的重复间隔设置为一个小时

If you want to set a custom interval, like for example 30 minutes, you need to create two notifications setting a scheduled difference of 30 minutes with FireDate and set the repeat interval of both notifications to an hour.

您猜对了。您需要创建四个通知并每小时重复一次。

You're guessing right. You would need to create four notification and repeat them every hour.

OP在评论中告诉他最后使用以下代码。我将其包含在我的答案中,以提高他给定信息的可读性。

//Repeat very 5 minutes
//Create 12 notifications fireing every hour with 5 minute intervals Notification.RepeatInterval := TRepeatInterval.Hour;
for I := 0 to 11 do
begin
  Notification.FireDate := Notification.FireDate + EncodeTime(0,(I*5),0,0);
  ANotificationcenter.ScheduleNotification(Notification);
end;

这篇关于自定义通知间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆