Reputation: 68
Already implemented something like this But it fails on mobile devices. As soon as the device browser goes in background (Screen lock/ user start another app / press home key) javascript counter stops counting idle time. I know this is OS behavior to optimize memory and CPU utilization but just curious is there any way to achieve expected behavior on mobile browser.
Upvotes: 1
Views: 248
Reputation: 4762
Instead of counting, you should store a timestamp in memory, when it become active again, compare this timestamp with now, and then do your action. You can do this with Date object and getTime().
Upvotes: 1