Vinayak B
Vinayak B

Reputation: 4520

Time cheating prevention in offline mode in android

I am creating an app which can monitor elapsed time taken for a particular task. The times are taken from server and its working fine. But when I added offline feature , I take time from System.currentTimeMillis(); . There is problem ,if user change their phone time ,then they can easily cheat the elapsed time. Is there any other way I can fetch duration of particular task interval.Or How can I prevent this cheating? I already search stack overflow for a good answer. but can't find anything. Please help

Upvotes: 4

Views: 3505

Answers (2)

meeeee
meeeee

Reputation: 2939

You could start a thread to count the elapsed time yourself. Place counter inside a service, to prevent it closing with the app. If the service if closed by the device restarting or whatever, then it needs to go online to confirm the time again before continuing.

As long as the device is not restarted or the service being closed by system due to low resources, the user will be able to stay offline.

Upvotes: 3

Teasel
Teasel

Reputation: 1340

From what I have seen through my research you'll have to store the time, on a server would be better to prevent the user to change it by accessing your app's files.

I believe these two links can give you a lead on the idea.

Preventing time manipulation.

Changing time on device.

Upvotes: 2

Related Questions