How to know the user’s inactivity?

jimpmathew

New Member
Licensed User
Longtime User
How to know the user’s inactivity from an application. Actually if user is inactive for a period I have to trigger some code. How can I do this. Please help.
 

NJDude

Expert
Licensed User
Longtime User
You will need a timer and reset it everytime there's some action, the attached sample displays a message box if the user has been inactive for 10 seconds.
 

Attachments

  • InactivitySample.zip
    10.2 KB · Views: 198
Upvote 0

jimpmathew

New Member
Licensed User
Longtime User
Thank you for the quick reply. It was really helpful. But I have so many panels and buttons in my application. Do I need to write the reset code on all the button and panels click events? Is there any simple way to do this?
 
Upvote 0

melamoud

Active Member
Licensed User
Longtime User
touch event

it might be good enough to override this sub and update the last visit time

B4X:
Sub Activity_Touch (Action As Int, X As Float, Y As Float)
   lastTimeAlive = DateTime.Now
End Sub

of course you need to set the timer, and remember to shut it down on activity pause sub, and turn it on on resume sub, etc
 
Upvote 0
Top