Reputation: 1363
I am designing an alarm clock app, and I need to listen to two system broadcasts: Intent.ACTION_TIME_CHANGED
and Intent.ACTION_DATE_CHANGED
.
I believe ACTION_TIME_CHANGED
is fired when the user manually changes the time. But when is ACTION_DATE_CHANGED
broadcasted?
The documentation of this action is not quite convincing. It says,
The date has changed.
Who changed the date? The user, by changing the date setting? Or did the clock tick over to the next day?
Two Stack Overflow answers that I found regarding this:
The two answers indicate completely different behaviour. If answer #1 is correct, I will listen to this broadcast using a context-registered receiver. If answer #2 is correct, I need to register a context-registered receiver for Intent.ACTION_TIME_TICK
and then manually check whether we are in the next day or the same day.
Upvotes: 1
Views: 1296
Reputation: 1363
As per the suggestion by @Nicolas, I tested both the broadcasts. The results:
ACTION_TIME_CHANGED
is broadcasted only when the user manually changes the date, time or time format (from 12-hour to 24-hour format or vice-versa).
ACTION_DATE_CHANGED
is broadcasted only when the day changes, i.e. when we go from 11:59 PM to 12:00 AM of the next day. This is automatically triggered by the system.
Upvotes: 2