Faisal Silitonga
Faisal Silitonga

Reputation: 433

How to prevent user changing system date/time (in Android)?

I have googled, but I can find no advice to prevent user change system date/time in android.

We are developing an Enterprise Application, we would like to prevent the user of the device to be able to set time settings. In other words, we want to set a policy which defines, that user cant change date and time in android device. Are there any recommendations to do this? Thanks.

Upvotes: 25

Views: 15794

Answers (4)

Ehsan Jelodar
Ehsan Jelodar

Reputation: 1544

you can save current time to db when application start and check every 1 minutes if current time not equal to db time+60 set system time to db time+60.

Upvotes: 1

Stephan Branczyk
Stephan Branczyk

Reputation: 9375

Here is a third alternative that should significantly save on battery life:

Register a BroadCast Receiver for when the time gets changed by the user. Then disable the app until the device time is checked against network-time or server-time.

Those Broadcast Receivers exist. I just checked now with this app called Internal Broadcast Monitor I just found on Google Play.

enter image description here

Here is the interesting part below where I changed both the time and the date:

enter image description here

And below is the part where I changed the time zone: enter image description here.

Upvotes: 5

Jason Hessley
Jason Hessley

Reputation: 1628

I don't know of any way that you can change the default behavior of the device.
You can however prevent your application from running if the system time differs from the network time. Or you could use the network time in your app instead of system time.

The answer to this post explains how to access the network time.

How can I get the "network" time, (from the "Automatic" setting called "Use network-provided values"), NOT the time on the phone?

Upvotes: 1

Nikolay Elenkov
Nikolay Elenkov

Reputation: 52936

Since there is no policy support for this in the device administrator framework, you can't. File a feature request, it might get added in a next version.

Upvotes: 3

Related Questions