Android - 找出现在是几点
我想使用 AlarmManager 来设置一个重复闹钟,每小时按时响起。我知道如何设置每小时重复的闹钟,但不知道如何从整点开始实际设置它,我需要知道下面的“whatTime”变量的值。
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME, whatTime, 1*60*60*1000, operation);
另外我希望能够设置一个标志,例如 - 如果时间恰好在白天 4 点到 8 点之间,则执行一些操作,否则不要打扰。
所以我真的需要知道如何找出一天中的时间,有人能告诉我该怎么做吗?非常感谢
I want to use and alarmManager that sets a repeating alarm to go off on the hour, every hour. I know how to set a repeating alarm every hour but not how to actually set it from the top of the hour, I need to know this value for the 'whatTime' variable below.
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME, whatTime, 1*60*60*1000, operation);
Also I want to be able to set a flag that for e.g. - if the time happens to be between 4 and 8 in the daytime, perform some operations, otherwise don't bother.
So I really need to know how to find out the hour of the day, can anyone tell me how to do this? Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
Try: