Reputation:
How to detect idle time in Corona? How to detect there is no user interaction or event with the device in a particular interval of time?The application what I am developing is based on user events.If the user doesn't provide any event for few minutes,the screen must be reloaded?Any idea about this with a sample code will be helpful.
Upvotes: 1
Views: 533
Reputation: 903
You need a screen tap listener:
local function onScreenTap( event )
idletime =0
end
Runtime:addEventListener( "tap", onScreenTap )
Upvotes: 0
Reputation: 179
Set up some counter which will count the idle time (maybe every second)... When user touch the screen this timer will be set back to 0 - so when this counter reach some value (for example 60) then reload you page...
This is counter:
local idletime = 0
local function countidle()
idletime = idletime + 1
if idletime == 60 then
-- Code for restart
end
end
timer.performWithDelay(1000, countidle, 0)
Then do some function which will reset idletime value on touch...
Hope it helps ;)
Upvotes: 1