Search code examples
androidunity-game-enginetimerbroadcastreceiver

ACTION_TIME_CHANGED Intent, can we set this to trigger based on a "set time"?


Just a quick question about this, for the android platform, I was directed to this link from another question..

Is there a way to detect when the user has changed the clock time on their device?

If the player changes their system time, this event would trigger. I would only like this event to trigger if the time changed is greater than 40 seconds, is this possible?

Is there a way to make this trigger for certain times only? for example, 30-40 seconds is no big deal for me, however anything over that, I would like this to fire, and then check in with a server to see if the user has tampered with their device time?

I realize there will be other things to worry about such as timezones, I think I can work that out if it is possible for this to only fire if the time changed is greater than 40 seconds.

This is from the documentation.. suggesting that this is not possible. Can anybody clarify?

public static final String ACTION_TIME_CHANGED

Added in API level 1 Broadcast Action: The time was set.

Constant Value: "android.intent.action.TIME_SET"


Solution

  • No, that isn't possible. This broadcast is sent when the time is set (changed). If you are listening for this broadcast Intent you will get it every time. There isn't a way to tell Android that you only want to get triggered under certain circumstances.