Reputation: 770
My App requires correct time (can not rely on device time since the user can change it + carrier might be not available or doesnt support NITZ). Initially I use http calls to a trusted server, however there are situations when network is not available.
Is there any other option I can use?
Can I rely on broadcast ACTION_TIME_CHANGED to detect that the user modofied the device clock? Does my app always need to be running in order to get this notification (this I would like to avoid)?
Thanks!
Upvotes: 4
Views: 2516
Reputation: 1006704
My App requires correct time
Never rely on the client for accurate time, on any platform.
Initially I use http calls to a trusted server, however there are situations when network is not available.
Then you cannot have accurate time, by definition.
Is there any other option I can use?
You can create your own firmware that prevents the user from setting the time.
Can I rely on broadcast ACTION_TIME_CHANGED to detect that the user modofied the device clock?
No, insofar as there are several possible reasons why that broadcast will be sent.
Does my app always need to be running in order to get this notification (this I would like to avoid)?
I can tell you that the only receivers of ACTION_TIME_CHANGED that I see in the Android source code are ones that register for it via registerReceiver()
, not the manifest. This broadcast does not fit the usual pattern where registerReceiver()
is required, though. It is probably simpler for you to just try it.
Upvotes: 3